Close

October 5, 2015

Magento Custom Bundle Pricing

One of the nice features about doing orders in the Magento back-end is the ability to create manual orders and setting a discount price. The only problem is that this custom pricing was only available with simple products.

We managed to create magento custom bundle pricing in just a few steps.

The first step was to figure out how the main order quote system now works in Magento EE 1.14*. Previously we were able to modify the code and set a flat quote on a bundle, without having to go through to many hoops. That functionality no longer works, and the order pricing seems dependent entirely on the simple products that make up the bundle.

So when you start a new manual order for a customer, we built the capability to edit the bundle items individually, and assign them custom prices.

The external tool we built to modify a custom bundle quote was a bit tricky to build, but it was essentially built by gathering the master Quote object, allowing and applying a custom price to the actual quote item.

 
                //get the individual cart item that is in the quote.
                $cartItem =$quoteObj->getItemById($objid);
              //set the custom prices
                $cartItem->setCustomPrice($price);
                $cartItem->setOriginalCustomPrice($price);
                // Enable super mode on the product.
                $cartItem->getProduct()->setIsSuperMode(true);
                $cartItem->save();  //save

After the prices are all set in the cart for that quote, the biggest key was calling “collectTotals” and “Save” on the quote object.

    $quoteObj->collectTotals();
    $quoteObj->save();

After you go back to the adminhtml order form, your new bundle item configuration should be displayed with your new bundle price.

The individual pricing on every component in the bundle provides a very robust solution for discounting orders, and shows the end customer precisely the discount they are getting on the order.

if you have any questions about adding a custom bundle admin pricing solution.