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

5
  • have you install any module for ajax ?
    – Keyul Shah
    Feb 22, 2014 at 10:30
  • no.my custom code for add to cart. Feb 22, 2014 at 10:43
  • can you please update the error so I can help you
    – Keyul Shah
    Feb 22, 2014 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. Feb 22, 2014 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, 2014 at 10:58

1 Answer 1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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