0

I have created a warranty as a product in magento which has 2 custom check box options. This product (warranty) does not have any specific page so I would like to display both the custom options of a warranty products as checkbox when selected one of the custom option the product (warranty) also should get added to the cart.

I want to display this addon product (warranty) only when the cart amount is larger then $2000. Is there any way to achieve this functionality? I have attached a screenshot below to illustrate the custom option.

Warranty option sample

1
  • Wouldn't getting quote's grand total amount work? Commented Feb 6, 2014 at 17:18

2 Answers 2

1

You can create observer for events checkout_cart_product_add_after and checkout_cart_product_update_after and in your observer you can check cart total and add or remove product from cart dynamically.
You can try below codes :
getting totals

$totals = Mage::getSingleton(‘checkout/session’)->getQuote()->getTotals();//Total object     
$subtotal = round($totals["subtotal"]->getValue());//Subtotal value 
$grandtotal = round($totals["grand_total"]->getValue()); //Grandtotal value

adding product to cart

$cart = Mage::getModel('checkout/cart');
$cart->init();
$cart->addProduct($my_product, array('qty' => $qty_value));
$cart->save(); 
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);

Similarly you can write for removing product from cart if while updating cart order total goes down the required amount.
Also in you can do necessary changes in item.phtml to remove remove link, qty update box and other stuff that you don't need.

0
0

For that you have to below steps. I will not provide you whole code but provide some Idea.

1) copy and paste the structure \app\design\frontend\base\default\template\checkout\cart.phtml file into your theme folder structure.

2) in that file at line no 127 add ne <td> </td> tag you can add your code like first check the condition of subtotal. To fetch Subtotal try below code.

$quote = Mage::getSingleton('checkout/cart')->getQuote();
$grandTotal = $quote->getGrandTotal();
if($grandTotal >= 2000)
{
   // write your warranty part code 
}
6
  • Hi Keyul, Thanks for the input. I am very new to Magento and I have been trying to make this function but with no luck. I did try out few options as you have suggested but with no success. Here the the link to my code: link. If possible can you look into the code?
    – Kevin S
    Commented Feb 6, 2014 at 17:31
  • just do one thing put my condition before foreach ($product->getOptions() as $o):?> so and run
    – Keyul Shah
    Commented Feb 6, 2014 at 17:33
  • Hi, I did try it out but it is showing only one single checkbox but the product has more then one custom option and the rest of the page code goes missing. I just want to populate all the custom option of a product id 142 with checkbox option when selected the product gets added to the cart. Right now even after selecting the checkbox nothing gets added to the cart.
    – Kevin S
    Commented Feb 6, 2014 at 17:39
  • I have guide you as but this is also new for me so I provide you suggestion I never this type of option in cart page for each product is it's fully customization. I work custom option in detail page not on checkout page .
    – Keyul Shah
    Commented Feb 6, 2014 at 17:41
  • But I think you are on right track
    – Keyul Shah
    Commented Feb 6, 2014 at 17:42

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.