2

I am adding virtual products to cart by my custom ajax function and now virtual products can only be added one in the cart.if i had second one in the cart it is generating error report as Nominal items can only be purchased as standlone.

I want to show this message on the alert box on the add to cart button page which should i get in the ajax response data.

MY code

$j.ajax({
                url: "<?php echo Mage::getUrl('customblocks/ajax/virtualpick2addtocart'); ?>",
                type: "POST",
                data: {pro_id:sel_pro_id,sel_pro_price:sel_pro_price},
                success: function(data){
                    //$j("#spinner1").hide();
                    location.href = checkout_url;
                },
                error: function(){
                }
            });

and my ajax add to cart code

$cart = Mage::getModel('checkout/cart');
    $cart->init();
    $cart->addProduct($_product,$params);
    $cart->save();

Thanks In Advance

  • have you install any module for ajax ? – Keyul Shah Feb 22 '14 at 10:30
  • no.my custom code for add to cart. – Pradeep Sanku Feb 22 '14 at 10:43
  • can you please update the error so I can help you – Keyul Shah Feb 22 '14 at 10:45
  • i had updated my code.and when i add first product add to cart it adds.but when i ad 2nd one.it thorws error called Nominal items can only be purchased standalone in the error log.i want to send this error to ajax response and need to show on the alert box. – Pradeep Sanku Feb 22 '14 at 10:51
  • you can do one thing in your request method you can do code for your cart and second time you got the same product then retun the error code based on that you can display the error message in alert – Keyul Shah Feb 22 '14 at 10:58
3

virtual != nominal

Nominal products are products with recurring profiles, and in Magento 1.x these must be purchased separately. What you are attempting cannot be done without extensive customization (either with effort by yourself or via a third-party module).

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.