Stepel Posted April 20, 2022 Share Posted April 20, 2022 Hi, I am trying to create my custom order in my module. Is there any chance to add product to cart with my custom price except creating a new product before ? If no , what should I do ? Create an order by myself and then change prices in order_details? The same question is about delivery cost ? Should I first create an order and then change prices ? Link to comment Share on other sites More sharing options...
Ress Posted April 20, 2022 Share Posted April 20, 2022 If you want to set a different price than the normal product price, you can create a SpecificPrice object, set the product and cart id and the new price. About the carrier price, I think so, you will have to make the changes afterwards. Link to comment Share on other sites More sharing options...
Stepel Posted April 22, 2022 Author Share Posted April 22, 2022 I am not sure how I can use this SpecificPrice object. I created this object and set fields. Then I called ->add() method but I don't have any result as I expected . I did it before add product to cart. Still product has the same price and order total amount is still the same 😕 Link to comment Share on other sites More sharing options...
Ress Posted April 22, 2022 Share Posted April 22, 2022 Well, you should do this after you add the product to the cart, because in the specific price, you set the product id and the cart id, and if the product is not added to the cart, I don't think it's okay. 1 Link to comment Share on other sites More sharing options...
Stepel Posted April 23, 2022 Author Share Posted April 23, 2022 Right, but still something doesn't work. I see that specific price works like kind of "discount" ?Should I set reduction ? I try to set price and reduction as 0 so I just want to force my custom price for this product. Link to comment Share on other sites More sharing options...
Ress Posted April 23, 2022 Share Posted April 23, 2022 Yes, it will work as a discount, you set the price directly, just like that. $specific_price = new SpecificPrice(); $specific_price->id_cart = $cart_id; $specific_price->id_shop = 0; $specific_price->id_group_shop = 0; $specific_price->id_currency = 0; $specific_price->id_country = 0; $specific_price->id_group = 0; $specific_price->id_customer = $customer_id; $specific_price->id_product = $product_id; $specific_price->price = $product_sale_price; // custom price $specific_price->from_quantity = 1; $specific_price->reduction = 0; $specific_price->reduction_type = 'amount'; $specific_price->add() Link to comment Share on other sites More sharing options...
Stepel Posted April 24, 2022 Author Share Posted April 24, 2022 Thank you, I was doing like you but I used real ids but when I set all to 0 it started to work So another problem is setting custom delivery/carrier price. If it is not possible to set it like specific price or during valideOrder method I have an idea that i create Order with my custom state which doesn't send email and then update carrier/deliver prices, update order total amount and then set order state to "typical" state. Probably another solution is create own "carrier" but I don't think it is good idea.. Link to comment Share on other sites More sharing options...
Stepel Posted April 24, 2022 Author Share Posted April 24, 2022 Another problem is that i see there is no option to call ValidateOrder and DON'T Send email. Even my custom state has checked "don't send email" it doesn't care and send confirmation mail. It looks I need to write unproperly email address and when I change carrier/deliver price i should correct email and then set current state to nomral one.. Link to comment Share on other sites More sharing options...
Ress Posted April 25, 2022 Share Posted April 25, 2022 Yes, sending the confirmation email cannot be stopped from settings or something. I think it's okay to do something like that, like you said, by changing your email address. Link to comment Share on other sites More sharing options...
Stepel Posted April 25, 2022 Author Share Posted April 25, 2022 Yes I did it like I said and it looks it works OK. Thank you for your help. 1 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