Stepel Posted April 16, 2022 Share Posted April 16, 2022 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. Link to comment Share on other sites More sharing options...
Ress Posted April 16, 2022 Share Posted April 16, 2022 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. 1 Link to comment Share on other sites More sharing options...
Stepel Posted April 16, 2022 Author Share Posted April 16, 2022 Thanks, I will try. I hope there will be less problems than by the API 😕 1 Link to comment Share on other sites More sharing options...
Stepel Posted April 19, 2022 Author Share Posted April 19, 2022 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.. Link to comment Share on other sites More sharing options...
Ress Posted April 20, 2022 Share Posted April 20, 2022 If you want to have control over the price of the product, you can use the SpecificPrice object. Link to comment Share on other sites More sharing options...
Stepel Posted June 18, 2022 Author Share Posted June 18, 2022 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 ? Link to comment Share on other sites More sharing options...
Ress Posted June 20, 2022 Share Posted June 20, 2022 Hi, For the value to include taxes, set property reduction_tax to 1 (from the SpecificPrice object, of course). Link to comment Share on other sites More sharing options...
Stepel Posted June 20, 2022 Author Share Posted June 20, 2022 (edited) I have reduction_tax = 1 but still product in final order has: price = mine price + VAT 😕 Edited June 21, 2022 by Stepel (see edit history) Link to comment Share on other sites More sharing options...
Ress Posted June 21, 2022 Share Posted June 21, 2022 Which way did you set the discount? Did you put the price directly? Or did you set a discount (amount or percentage) Link to comment Share on other sites More sharing options...
Stepel Posted June 21, 2022 Author Share Posted June 21, 2022 $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. Link to comment Share on other sites More sharing options...
Ress Posted June 21, 2022 Share Posted June 21, 2022 If you set the price directly, yes, it is the one without tax. That property works when you set the discount amount. Link to comment Share on other sites More sharing options...
Stepel Posted June 21, 2022 Author Share Posted June 21, 2022 Do you mean reduction property ? What should I set then in price property ? Link to comment Share on other sites More sharing options...
Ress Posted June 22, 2022 Share Posted June 22, 2022 (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, 2022 by Ress (see edit history) Link to comment Share on other sites More sharing options...
Stepel Posted June 22, 2022 Author Share Posted June 22, 2022 I did it in different way. I just calculate price without tax.. i hope this will be OK solution. Thanks for your help. 1 Link to comment Share on other sites More sharing options...
Stepel Posted July 3, 2022 Author Share Posted July 3, 2022 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 😕 Link to comment Share on other sites More sharing options...
Stepel Posted July 3, 2022 Author Share Posted July 3, 2022 Ok, I found solution Link to comment Share on other sites More sharing options...
Nietypowy Informatyk Posted July 5, 2022 Share Posted July 5, 2022 @Stepel Hi! Is there any chance, that you would share code responsible for creating new order with us? Link to comment Share on other sites More sharing options...
Stepel Posted July 5, 2022 Author Share Posted July 5, 2022 @Nietypowy Informatyk Hi, I can help with advices but all code I can't share It was customized module for my customer and it wasn't free Link to comment Share on other sites More sharing options...
Stepel Posted July 25, 2022 Author Share Posted July 25, 2022 @Ress Can you tell me what is the easiest or the best way to check availability/stock product before add to cart ? Link to comment Share on other sites More sharing options...
Ali Samie Posted July 25, 2022 Share Posted July 25, 2022 To add a new order, you need to do the exact steps in checkout process. 1. Login as a customer or a guest 2. Add Ites to cart 3. Add a new address or create one and set as delivery and invoice address 4. Set a carrier 5. Place order with validateOrder method. In order to use validate order, you need to create a payment module. In conclusion, you have to create a payment module, which lets you validate an order and submit that. Link to comment Share on other sites More sharing options...
Ali Samie Posted July 25, 2022 Share Posted July 25, 2022 36 minutes ago, Stepel said: @Ress Can you tell me what is the easiest or the best way to check availability/stock product before add to cart ? You should use the StockAvailable class to get available quantities of a product, either simple or with combinations Link to comment Share on other sites More sharing options...
Ress Posted July 26, 2022 Share Posted July 26, 2022 17 hours ago, Stepel said: @Ress Can you tell me what is the easiest or the best way to check availability/stock product before add to cart ? You can see exactly what checks are normally done, in CartController, processChangeProductInCart method. You can follow the same steps. 1 Link to comment Share on other sites More sharing options...
Stepel Posted July 26, 2022 Author Share Posted July 26, 2022 Ok i did it already:) thank you guys. 2 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