Jay Vachhani Posted September 4 Share Posted September 4 $carrier = new Carrier(); $carrier->name = $carrier_name; $carrier->is_module = true; $carrier->active = true; $carrier->is_free = false; $carrier->shipping_handling = false; $carrier->shipping_external = 1; $carrier->shipping_method = 1; // 0 = default, 1 = weight, 2 = price $carrier->external_module_name = "Paack"; $carrier->need_range = 1; $carrier->range_behavior = 1; $carrier->delay = array(Language::getIdByIso('en') => 'Delivery within 24 hours.'); $carrier->id_tax_rules_group = 0; // Tax rules group ID $carrier->url = ''; $carrier->img = dirname(__FILE__).'views/img/paack.png'; if ($carrier->add()) { // Save the carrier ID to the configuration //Configuration::updateValue($config_key . '_ID', (int)$carrier->id); Configuration::updateValue($config_key, (int)$carrier->id); // Example: Assign to all ranges and zones $ranges = RangePrice::getRanges($carrier->id); if (!$ranges) { // Create default ranges if necessary $range = new RangePrice(); $range->id_carrier = $carrier->id; $range->delimiter1 = 0; $range->delimiter2 = 1000000; $range->add(); } // Create weight range $rangeWeight = new RangeWeight(); $rangeWeight->id_carrier = $carrier->id; $rangeWeight->delimiter1 = '0'; $rangeWeight->delimiter2 = '10000'; $rangeWeight->add(); // Assign to all zones $zones = Zone::getZones(true); foreach ($zones as $zone) { Db::getInstance()->insert('carrier_zone', [ 'id_carrier' => (int)$carrier->id, 'id_zone' => (int)$zone['id_zone'] ]); $price_list[] = [ 'id_range_price' => (int) $range->id, 'id_range_weight' =>(int) $rangeWeight->id, 'id_carrier' => (int) $carrier->id, 'id_zone' => (int) $zone['id_zone'], 'price' => (float) 50 ]; } $carrier->addDeliveryPrice($price_list, true); $groups = Group::getGroups(true); foreach ($groups as $group) { Db::getInstance()->insert('carrier_group', array( 'id_carrier' => (int)$carrier->id, 'id_group' => (int)$group['id_group'] )); } // Copy the carrier logo copy(dirname(__FILE__).'/views/img/paack.png', _PS_SHIP_IMG_DIR_.'/'.(int)$carrier->id.'.jpg'); return true; } return false; 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