Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(dirname(__FILE__).'/config/config.inc.php');
- include(dirname(__FILE__).'/init.php');
- // Adding 21% tax
- $tax_name = "VES - 21% Tax";
- // Creating Tax
- $tax = new Tax();
- $tax->name = [Context::getContext()->language->id => $tax_name];
- $tax->rate = 21.000;
- $tax->active = true;
- $tax->add();
- // Creating Tax Rule Group, for all countries
- $countries = Country::getCountries(Context::getContext()->language->id);
- $selected_countries = array();
- foreach ($countries as $country) {
- $selected_countries[] = (int) $country['id_country'];
- }
- $selected_states = array(0);
- $tax_rules_group = new TaxRulesGroup();
- $tax_rules_group->active = true;
- $tax_rules_group->name = $tax_name;
- $tax_rules_group->add();
- foreach ($selected_countries as $id_country) {
- $first = true;
- foreach ($selected_states as $id_state) {
- $id_rule = null;
- $zip_code = 0;
- $tr = new TaxRule();
- $tr->id_tax = $tax->id;
- $tr->id_tax_rules_group = (int)$tax_rules_group->id;
- $tr->id_country = (int)$id_country;
- $tr->id_state = (int)$id_state;
- list($tr->zipcode_from, $tr->zipcode_to) = $tr->breakDownZipCode($zip_code);
- $tr->behavior = (int) 0;
- $tr->description = '';
- // Construct Object Country
- $country = new Country((int)$id_country, (int)Context::getContext()->language->id);
- $tr->id = (int)$tax_rules_group->getIdTaxRuleGroupFromHistorizedId((int)$tr->id);
- $tr->id_tax_rules_group = (int)$tax_rules_group->id;
- $tr->save();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement