1

I'm developing a bundle product module for magento 1.7

The module is working as expected with bundle products, however, issue appears with standard Magento configurable products - once I select size (simple product) and add it to cart, it automatically doubles product quantity.

For example:

  • if we have an Item 'X' in Size 'S' Qty = 1 : we will not be able to add it to the cart and there will be "The requested quantity for Item 'X' is not available"
  • Although if we change Item 'X' in Size 'S' Qty = 2, but still adding Item 'X' in Size 'S' Qty = 1 to cart, then we are able to cart and checkout this item (note!! at this step magento will create an invoice with correct qty = 1 and prices, but once order is placed, Magento back-end will remove qty=2 from db row)

I have extended Mage_Checkout_Model_Cart with following:

/**
 * Get request for product add to cart procedure
 *
 * @param   mixed $requestInfo
 * @return  Varien_Object
 */
protected function _getProductRequest($requestInfo)
{
    if ($requestInfo instanceof Varien_Object) {
        $request = $requestInfo;
    } 
    elseif (is_numeric($requestInfo)) {
        $request = new Varien_Object(array('qty' => $requestInfo));

    } 
    else {

         if(isset($requestInfo['bundle_has_custom_options'])){
            if(!empty($requestInfo['options'])){
                foreach($requestInfo['bundle_simple_custom_options'] as $id => $opt){
                    foreach($opt['options'] as $key => $o){
                        $opt['options'][$key] = $requestInfo['options'][$key];
                        $requestInfo['bundle_simple_custom_options'][$id] = $opt;
                    }
                }
            }
            unset($requestInfo['options']);
        }            
        $request = new Varien_Object($requestInfo);
    }

    if (!$request->hasQty()) {
        $request->setQty();
    }

    return $request;

}

Could it be that qty double comes because the system is adding qty=1 from extended bundle cart function and qty=1 from standard configurable cart function?

If any further info required, please let me know.

1

Is difficult to say without knowing what your bundle product module does or whether it handles with Qty. Do you have some observer checking for such in any add_to_cart events?

I have seen that for bundles even when the Qty of the whole bundle is 0 in the product detail view, this get increased to 1 when you add it in cart.

You can debug this file to start with something: app/design/frontend/base/default/template/catalog/product/view/addtocart.phtml check output here: echo $this->getProductDefaultQty() * 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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