peorthyr Posted June 11, 2015 Share Posted June 11, 2015 Good day all. I'm searching a way to create a new product via PHP, and to add a specific tax rate to it. $product = new Product(); //$product->ean13 = 9999999999999; $product->reference = $etichetta; $product->name = array((int)Configuration::get('PS_LANG_DEFAULT') => $titolo); $product->description_short = array((int)Configuration::get('PS_LANG_DEFAULT') => $testo); $product->description = array((int)Configuration::get('PS_LANG_DEFAULT') => $composizione); $product->price = $prezzo; $product->link_rewrite = array((int)Configuration::get('PS_LANG_DEFAULT') => $safeName); $product->id_category = 23; $product->id_category_default = 23; $product->redirect_type = '404'; $product->add(); $product->addToCategories(array(23)); $product->id_tax_rules_group = 3; <------------------- this is not working, the tax is always "the default one". everything is working fine except the taxes, it uses always the default taxes (22%)... what i'm mistaking?? Link to comment Share on other sites More sharing options...
tuk66 Posted June 16, 2015 Share Posted June 16, 2015 id_tax_rules_group is not a tax rate ID. It is a tax rule ID (ps_tax_rule table). Link to comment Share on other sites More sharing options...
peorthyr Posted June 16, 2015 Author Share Posted June 16, 2015 good point, is there a way to set the id of the tax rule I want the product will use when bought? Link to comment Share on other sites More sharing options...
Zeben Posted June 16, 2016 Share Posted June 16, 2016 Sorry to ask in this post but do not know how to open a new one to ask the question. Does anyone know how to add a rule imposed from php? Best regards, thank you. Link to comment Share on other sites More sharing options...
peorthyr Posted June 17, 2016 Author Share Posted June 17, 2016 (edited) it mostly depends on your script logic, you can use the PS framework, you can directly update the db, you can even use webservices to achieve that task. sidenote, you can start a new topic by pressing the button "start a new topic" in any thread list on the forum (the page before this one). post here (or on a new topic) your problem, with some code and logic, let's see if there is a way to accomplish that. Edited June 17, 2016 by peorthyr (see edit history) 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