Stepel Posted April 16 Posted April 16 Hi, what is the best way to create new order in my custom module ? Should I create all elements by new Order(), new Cart() etc etc manually or there is some suggested method or class to do it ? Thanks for your help. Share this post Link to post Share on other sites More sharing options...
Ress Posted April 16 Posted April 16 You will need to use or create a customer and an address to use as a delivery and billing address. After that you will have to create a shopping cart, and add the products in it. Next, you will need to call the validatedOrder() function in the PaymentModule class to create the order, and of course you need to assign it a carrier, and create the OrderCarrier object for the current order. Share this post Link to post Share on other sites More sharing options...
Stepel Posted April 16 Posted April 16 Thanks, I will try. I hope there will be less problems than by the API 😕 1 Share this post Link to post Share on other sites More sharing options...
Stepel Posted April 19 Posted April 19 Hmm I have some doubts about using validatedOrder() method. I created customer, addresses and cart but I see that i can add products by id_product. I would like to have influence on product price and carrier price. I see that I can set those prices in order_details and order so I am not sure if I should use validatedOrder method. I think that it will work like by API and will change prices to be equel with those prices in official product list etc.. Share this post Link to post Share on other sites More sharing options...
Ress Posted April 20 Posted April 20 If you want to have control over the price of the product, you can use the SpecificPrice object. Share this post Link to post Share on other sites More sharing options...
Stepel Posted June 18 Posted June 18 Hi again. I did it like you suggested. Thank you very much. It looks almost all is OK but I have case like i created SpecificPrice.. and in my mind was that price included tax but in order finally product has calculated tax again hm. Where and when I can set kind of "use_tax" parameter ? Share this post Link to post Share on other sites More sharing options...
Ress Posted June 20 Posted June 20 Hi, For the value to include taxes, set property reduction_tax to 1 (from the SpecificPrice object, of course). Share this post Link to post Share on other sites More sharing options...
Stepel Posted June 20 Posted June 20 (edited) I have reduction_tax = 1 but still product in final order has: price = mine price + VAT 😕 Edited June 21 by Stepel (see edit history) Share this post Link to post Share on other sites More sharing options...
Ress Posted June 21 Posted June 21 Which way did you set the discount? Did you put the price directly? Or did you set a discount (amount or percentage) Share this post Link to post Share on other sites More sharing options...
Stepel Posted June 21 Posted June 21 $sp = new SpecificPrice(); $sp->id_shop = 0; $sp->id_cart = $cart_id; $sp->id_product = $product_id; $sp->id_currency = 0; $sp->id_country = 0; $sp->id_group = 0; $sp->id_shop_group = 0; $sp->id_customer = $customer_id; $sp->price = $price; $sp->from_quantity = 1; $sp->reduction = 0; $sp->reduction_tax = 1; $sp->reduction_type = 'amount'; $sp->from = '0000-00-00 00:00:00'; $sp->to = '0000-00-00 00:00:00'; if ($sp->add()) { return $sp->id; } else { return null; } I do it like that so I set price directly and reduction as 0. Share this post Link to post Share on other sites More sharing options...
Ress Posted June 21 Posted June 21 If you set the price directly, yes, it is the one without tax. That property works when you set the discount amount. Share this post Link to post Share on other sites More sharing options...
Stepel Posted June 21 Posted June 21 Do you mean reduction property ? What should I set then in price property ? Share this post Link to post Share on other sites More sharing options...
Ress Posted June 22 Posted June 22 (edited) From what I see in the database, if you set the amount and leave the price as it is, it is saved -1 in the "price" property. Edited June 22 by Ress (see edit history) Share this post Link to post Share on other sites More sharing options...
Stepel Posted June 22 Posted June 22 I did it in different way. I just calculate price without tax.. i hope this will be OK solution. Thanks for your help. 1 Share this post Link to post Share on other sites More sharing options...
Stepel Posted 10 hours ago Posted 10 hours ago Hmm I have weird situation yet. Maybe it's fault of some cache.. I changed email address in database for customer but this: $this->context->customer = new Customer((int) $this->context->cart->id_customer); returns email before changed 😕 Share this post Link to post Share on other sites More sharing options...
Stepel Posted 9 hours ago Posted 9 hours ago Ok, I found solution Share this post Link to post 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