Jump to content

overriding AdminCarrierWizardController


Recommended Posts

i am overfiding AdminCarrierWizardController controoler getTplRangesVarsAndValues()

protected function getTplRangesVarsAndValues($carrier, &$tpl_vars, &$fields_value) {
        /*
        $tpl_vars['zones'] = State::getStatesByIdCountry(5);
        foreach ($tpl_vars['zones'] as $key => $value) {
            $tpl_vars['zones'][$key]['id_zone'] = $value['id_state'];
        }
        */
        $tplsss = ZoneCore::getZones(FALSE);
        print_r($tplsss);
        $tpl_vars['zones'] = State::getStatesByIdCountry(5);
        foreach ($tpl_vars['zones'] as $key => $value) {
            $tpl_vars['zones'][$key]['id_zone']=$value['id_state'];
            unset($tpl_vars['zones'][$key]['id_state']);
            unset($tpl_vars['zones'][$key]['id_country']);
            unset($tpl_vars['zones'][$key]['iso_code']);
            unset($tpl_vars['zones'][$key]['tax_behavior']);
        }
        $carrier_zones = Db::getInstance()->executeS('
			SELECT *
			FROM `' . _DB_PREFIX_ . 'carrier_zone` cz
			LEFT JOIN `' . _DB_PREFIX_ . 'state` z ON cz.`id_zone` = z.`id_state`
			WHERE cz.`id_carrier` = ' . (int) $carrier->id);
        $carrier_zones_ids = array();
        if (is_array($carrier_zones))
            foreach ($carrier_zones as $carrier_zone)
                $carrier_zones_ids[] = $carrier_zone['id_state'];

        $range_table = $carrier->getRangeTable();
        $shipping_method = $carrier->getShippingMethod();
        $zones = State::getStatesByIdCountry(5);
        foreach ($zones as $zone) {
            $fields_value['zones'][$zone['id_state']] = Tools::getValue('zone_' . $zone['id_state'], (in_array($zone['id_state'], $carrier_zones_ids)));
        }
        if ($shipping_method == Carrier::SHIPPING_METHOD_FREE) {
            $range_obj = $carrier->getRangeObject($carrier->shipping_method);
            $price_by_range = array();
        } else {
            $range_obj = $carrier->getRangeObject();
            $price_by_range = Carrier::getDeliveryPriceByRanges($range_table, (int) $carrier->id);
        }
        foreach ($price_by_range as $price)
            $tpl_vars['price_by_range'][$price['id_' . $range_table]][$price['id_zone']] = $price['price'];

        $tmp_range = $range_obj->getRanges((int) $carrier->id);
        $tpl_vars['ranges'] = array();
        if ($shipping_method != Carrier::SHIPPING_METHOD_FREE)
            foreach ($tmp_range as $id => $range) {
                $tpl_vars['ranges'][$range['id_' . $range_table]] = $range;
                $tpl_vars['ranges'][$range['id_' . $range_table]]['id_range'] = $range['id_' . $range_table];
            }

        // init blank range
        if (!count($tpl_vars['ranges']))
            $tpl_vars['ranges'][] = array('id_range' => 0, 'delimiter1' => 0, 'delimiter2' => 0);
    }

when i add the carrier, the database ps_carrier_zone not work,why?

Link to comment
Share on other sites

×
×
  • Create New...