1

In cross sell product,every product has different add to cart button.But i need checkboxes for every product and single add to cart button,which on clicked the selected product gets added to the cart. Below is the functionality image i am trying to achieve enter image description here

I am new to magento,any help would be appreciated

1 Answer 1

1

Siddhant,You need a customization

  • First, you need to an add form <form></from> which may be located at app/design/frontend/Your_package/Your_theme/template/checkout/cart/crossell.phtml
  • And add a checkbox beside each product and that checkbox name should be dynamic like and sending product id at this field

<input type="checkbox" id="crossell-checkbox<?php echo $_item->getProduct()->getId() ?>" name="crossell[]" value="<?php echo $_item->getProduct()->getId() ?>" />

  • Then create a controller where you would be submit this form and fetch the crossell field values and cart those checked products programmatically

    $productIds=$this->getRequest()->getParam('crossell');
    if (!empty($productIds)) {
                foreach ($productIds as $productId) {
                  $_product = Mage::getModel('catalog/product')->load($productId);
                  $cart = Mage::getModel('checkout/cart');
                  $cart->init();
                  $cart->addProduct($_product, array('qty' => $qty));
                  $cart->save();
              }
    }
    
2
  • What will be the form action url?
    – Siddhant
    Apr 22, 2016 at 13:50
  • i already told you ,you need to create create a new module's with a controller
    – Amit Bera
    Apr 24, 2016 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.