Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. <?php
  2.  
  3. require_once(dirname(__FILE__).'/config/config.inc.php');
  4. include(dirname(__FILE__).'/init.php');
  5.  
  6. // Adding 21% tax
  7. $tax_name = "VES - 21% Tax";
  8.  
  9. // Creating Tax
  10. $tax = new Tax();
  11.  
  12. $tax->name = [Context::getContext()->language->id => $tax_name];
  13. $tax->rate = 21.000;
  14. $tax->active = true;
  15.  
  16. $tax->add();
  17.  
  18. // Creating Tax Rule Group, for all countries
  19. $countries = Country::getCountries(Context::getContext()->language->id);
  20. $selected_countries = array();
  21.  
  22. foreach ($countries as $country) {
  23. $selected_countries[] = (int) $country['id_country'];
  24. }
  25.  
  26. $selected_states = array(0);
  27.  
  28. $tax_rules_group = new TaxRulesGroup();
  29. $tax_rules_group->active = true;
  30. $tax_rules_group->name = $tax_name;
  31.  
  32. $tax_rules_group->add();
  33.  
  34. foreach ($selected_countries as $id_country) {
  35.  
  36. $first = true;
  37.  
  38. foreach ($selected_states as $id_state) {
  39.  
  40. $id_rule = null;
  41. $zip_code = 0;
  42.  
  43. $tr = new TaxRule();
  44.  
  45. $tr->id_tax = $tax->id;
  46. $tr->id_tax_rules_group = (int)$tax_rules_group->id;
  47. $tr->id_country = (int)$id_country;
  48. $tr->id_state = (int)$id_state;
  49. list($tr->zipcode_from, $tr->zipcode_to) = $tr->breakDownZipCode($zip_code);
  50. $tr->behavior = (int) 0;
  51. $tr->description = '';
  52.  
  53. // Construct Object Country
  54. $country = new Country((int)$id_country, (int)Context::getContext()->language->id);
  55.  
  56. $tr->id = (int)$tax_rules_group->getIdTaxRuleGroupFromHistorizedId((int)$tr->id);
  57. $tr->id_tax_rules_group = (int)$tax_rules_group->id;
  58. $tr->save();
  59. }
  60. }
  61.  
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement