Jump to content

Adding products to Package list in Cart


Recommended Posts

Hi,

 

I am developing a new Payment module for Internet secure. I need to add extra charge in cart total. So I am adding a new product to the cart with the extra charge value. The problem is that I am able to add products to cart but the new product is not added to package list which prevents it to be added to final order (as from validateOrder function package list is converted to orderDetails table records). When I refresh (resubmit the form) the product is now added to package list as well. 

I would really appreciate if anybody could please help me to solve this problem. (I know the way I am adding extra charge is not the correct one so I welcome suggestions about it too)

 

Thanks

Link to comment
Share on other sites

Hi Nemo1, 

Thanks for your reply. Link to my website is: http://dpfoc.ca/demos/troy

What I am currently doing is I am generating a product once the payment form is submitted. Now taking the ID of newly generated product I use $cart->updateQty('1', $extra_pr_id, null, false, 'up', $id_address_delivery, new Shop($this->context->shop->id), true);

Now the product is added to cart as when I call $this->context->cart->getProducts(true); function it returns the product. But validateOrder function calls $this->context->cart->getPackageList(); function and my product is not added to product_list index of the returned array which results it not being added to actual order. But when I refresh the page (putting die in between) and call $this->context->cart->getPackageList(); function, it returns the product list with the extra charge product too.

I hope I have made myself clear. Please tell me if you need any more details.

 

Thanks again for your help.

Link to comment
Share on other sites

To check what I am talking about please add a product to cart by calling $cart->updateQty(...) and call $cart->getPackageList(false) right after that. The second function is used by prestashop to get attributes from cart and set them in order object.

Really need help here.

Thanks

Edited by preetam23 (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...