zawiszaty Posted January 6, 2020 Share Posted January 6, 2020 Hey, I have small problem with my custom module. I add to custom field on product page, customer put to this inputs a text and when his add the product to cart, automatically will be added another item with prize = count of text with custom inputs * prize for letter from module configuration. I do module configuration etc. but i dont know how to add this custom item. Link to comment Share on other sites More sharing options...
zawiszaty Posted January 6, 2020 Author Share Posted January 6, 2020 @ndiaga all product must have this custom fields🤔 Link to comment Share on other sites More sharing options...
CedCommerce Team Posted January 9, 2020 Share Posted January 9, 2020 On 1/7/2020 at 2:56 AM, zawiszaty said: Hey, I have small problem with my custom module. I add to custom field on product page, customer put to this inputs a text and when his add the product to cart, automatically will be added another item with prize = count of text with custom inputs * prize for letter from module configuration. I do module configuration etc. but i dont know how to add this custom item. Hi, There are 2 points need to be updated for your requirement to fulfilled, you may try the below points => First you need to create that custom item as product because while adding in cart you need product id $context = Context::getContext(); $cart = $context->cart; $cart->updateQty((int)($qty), (int)($id_product),0);custom product id you want to add $cart->update(); => For price of that item you can set Specific price for current cart and product you added $sp = new SpecificPrice(); $sp->id_product = (int)$id_product; // custom product id you want to add $sp->id_product_attribute = 0 $sp->id_cart = (int)$current_id_cart; $sp->from_quantity = 1; $sp->price = $new_price_without_tax; $sp->reduction_type = 'amount'; $sp->reduction_tax = 1; $sp->reduction = 0; $sp->from = "0000-00-00 00:00:00"; $sp->to = "0000-00-00 00:00:00"; $sp->add(); let us know if still any query 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