auroncaos Posted January 29, 2022 Share Posted January 29, 2022 Hello there, I have a problem with a "cart_rule" already created, I add it on a Cart with some product and on the cart it show correctly. I use: $cart ->addCartRule($cart_rule->id); then I save the cart and it's show all right. I create an order $order = new Order(); $product_list = $cart->getProducts(); $order->id_carrier = $id_carrier; //my data, working fine $order->id_customer = $id_customer; $order->id_address_invoice = (int)$id_address; $order->id_address_delivery = (int)$id_address; $order->id_currency = 2; $order->id_lang = 2; $order->id_cart = $id_cart; $order->reference = $my_reference; $order->id_shop = 1; $order->id_shop_group = 1; $order->secure_key = $customer->secure_key; $order->payment = "Bank wire"; //change if need $order->module = "bankwire"; //change if need $order->recyclable = 0; $order->gift = (int)0; $order->gift_message = ""; $order->mobile_theme = 0; $order->conversion_rate =1.000000; -- I set the amount to pay, discount, etc. then I execute $result = $order->add(); // Insert new Order detail list using cart for the current order $order_detail = new OrderDetail(null, null, null); $order_detail->createList($order, $cart, 1, $product_list, 0, true, 0); $order_detail_list[] = $order_detail; // I set manually my order_detail //then $history = new OrderHistory(); $history->id_order = (int)$order->id; $history->changeIdOrderState((int)10, $order->id); $history->save(); $order_carrier = new OrderCarrier(); $order_carrier->id_order = (int)$order->id; $order_carrier->id_carrier = (int)$id_carrier; $order_carrier->weight = (float)$order->getTotalWeight(); $order_carrier->shipping_cost_tax_excl = (float)$order->total_shipping_tax_excl; $order_carrier->shipping_cost_tax_incl = (float)$order->total_shipping_tax_incl; $order_carrier->add(); It's works just fine, i can write the amount I want etc... I have only a problem, even if the cart rule (a discount) is applied at the cart, when I change the state of the order in payment accepted, the cart_rules saved don't change, the amount of the discount don't decrease, like it was infinite... ANy suggestion? thanks 🙂 Link to comment Share on other sites More sharing options...
auroncaos Posted January 30, 2022 Author Share Posted January 30, 2022 ps: I already try to use Order_cart_rule too, in the same way, I can't find the function to "use" and "decrease" the voucher 😞 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now