Jump to content

Edit History

auroncaos

auroncaos

Hello there, I have a list of control / function for add by php a "new" product (not listed) in a new cart if cart not already exists, otherwise just add the product in the current cart of the selected users with

$cart->updateQty(1, $ID_PRODUCT);

I have included the following:
 

require_once('config/config.inc.php');
require_once('init.php');

 

 

Now I need a function for add a product in a actual order (after a check if the order is still avaiable for editing, like "waiting for payment" etc) 
No problem on the check, but in the adding, there is some function I can use? 


Somebody can help me with some hint?

 

for now I have this:

//for example, my order have id 10, so I use 10

$order= new Order(10);
$id_cart = $order->id_cart;

$cart = new Cart($id_cart);

//I have an ID product to add called $id_product
$cart -> updateQty(1,$id_product);
$cart->update();
$cart->save();
$id_carrier = $order->id_carrier;
 
$order->total_products = (float)$cart->getOrderTotal(false, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_products_wt = (float)$cart->getOrderTotal(true, Cart::ONLY_PRODUCTS, $order->product_list, $id_carrier);
$order->total_discounts_tax_excl = (float)abs($cart->getOrderTotal(false, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts_tax_incl = (float)abs($cart->getOrderTotal(true, Cart::ONLY_DISCOUNTS, $order->product_list, $id_carrier));
$order->total_discounts = $order->total_discounts_tax_incl;

$order->total_shipping_tax_excl = (float)$cart->getPackageShippingCost((int)$id_carrier, false, null, $order->product_list);
$order->total_shipping_tax_incl = (float)$cart->getPackageShippingCost((int)$id_carrier, true, null, $order->product_list);
$order->total_shipping = $order->total_shipping_tax_incl;


$order->total_wrapping_tax_excl = (float)abs($cart->getOrderTotal(false, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping_tax_incl = (float)abs($cart->getOrderTotal(true, Cart::ONLY_WRAPPING, $order->product_list, $id_carrier));
$order->total_wrapping = $order->total_wrapping_tax_incl;

$order->total_paid_tax_excl = (float)Tools::ps_round((float)$cart->getOrderTotal(false, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid_tax_incl = (float)Tools::ps_round((float)$cart->getOrderTotal(true, Cart::BOTH, $order->product_list, $id_carrier), _PS_PRICE_COMPUTE_PRECISION_);
$order->total_paid = $order->total_paid_tax_incl;
$order->round_mode = Configuration::get('PS_PRICE_ROUND_MODE');
$order->round_type = Configuration::get('PS_ROUND_TYPE');

 $order->update();
  $order->save();	

this give an updated cart of references, an updated total price and so on, but the "internal cart" aka the order details are not updated.
i tried several ways but I can't find anything.

I got the order detail at least (always with 10 as ID) 
 $list= OrderDetail::getList(10);

 

 

 

auroncaos

auroncaos

Hello there, I have a list of control / function for add by php a "new" product (not listed) in a new cart if cart not already exists, otherwise just add the product in the current cart of the selected users with

$cart->updateQty(1, $ID_PRODUCT);

I have included the following:
 

require_once('config/config.inc.php');
require_once('init.php');

 

Now I need a function for add a product in a actual order (after a check if the order is still avaiable for editing, like "waiting for payment" etc) 
No problem on the check, but in the adding, there is some function I can use? 
Somebody can help me with some hints? thanks

×
×
  • Create New...