Thứ Ba, 10 tháng 5, 2016

Magento increase product or service to be able to


shopping cart software making use of ajax
In this kind of websitewe could
proceeding to go over on
just how to put product that ajax add to cart magento will shopping cart employing ajax.Following little
research i actually located some valuable
here is how to incorporate product
in order to the wagon with no reloading the particular

webpage. The diverse approach you can consider are usually below
.
Approach 1: Generate out regarding box script and give us a call at in which script file working with ajax call.
- It may be very good in case you have
 basic product or service only. create screenplays program in root document simultaneous to app binder that one php record, replicate computer code mentioned bellow
 and give us a call this file and also complete parameter using receive approach.


view plaincopy to be able to clipboardprint?
include_once '.. /app/Mage. php';
Mage:: app();
test  
    $result = array();
    if(!isset($_GET['sku']))  
        $sku = '';
     
    else  
        $sku = $_GET['sku'];
     
    if(!isset($_GET['product_id']))  
        $product_id = '';
     
    else  
        $product_id = $_GET['product_id'];
     
    if(!isset($_GET['qty']))  
        $qty = '1';
     
    else  
        $qty = $_GET['qty'];
     
    if ($sku != "")
        $product_id = Mage::getModel('catalog/product')->  getIdBySku("$sku");
        if ($product_id == '')  
            $session->  addError("  <strong>  Product Not Added  </strong>  The SKU you entered ($sku) was not found.");
        }
    }
    $request = Mage::app()->  getRequest();
    $product = Mage::getModel('catalog/product')->  load($product_id);
    $session = Mage::getSingleton('core/session', array('name'=>  'frontend'));
    $cart = Mage::helper('checkout/cart')->  getCart();
    $cart->  addProduct($product, $qty);
    $session->  setLastAddedProductId($product->  getId());
    $session->  setCartWasUpdated(true);
    $cart->  save();
    $items_in_cart = Mage::helper('checkout/cart')->  getSummaryCount();
    $result['result']="success";
    $result['message']="Added!";
    $result['items_in_cart'] = "$items_in_cart";
    echo json_encode($result);
}
catch (Exception $e) {
    $result['result'] = 'error';
    $result['message'] =  $e->  getMessage();
    echo json_encode($result);

Method 2: Inside next method we can easily push merchandise using ajax call find method (that is all the particular details are part of website. ).
I have analyzed that for simple solution,configurable product and
package deal device. You have for you to just magento affiliate extension   make sure this characteristic and value chez is made up in proper structure. I use composed the structure website address, this will aid you to understand on which should be the web address format intended for while incorporating the product for the purchasing cart using ajax.

Example of this 1: Add Simple item using following format.
www.domain.com/index.php/checkout/cart/add?product=[id]&qty=[qty]

Case in point 2: Add configurable product or service using following format.
www.domain.com/index.php/checkout/cart/add?product=$id&qty=$qty&options[$id]=$value

Example a few: Add bundle product utilizing following format.
www.domain.com/index.php/checkout/cart/add?product=13&qty=1&options[12]=57

Note: In circumstance regarding magento coupon extension  configurable or
 bunch product you could have to check out the response html page to get error message, when virtually any.              

0 nhận xét:

Đăng nhận xét

Copyright © 2012 Extension magento free All Right Reserved