Jump to content

Recommended Posts

Hello, i am developing a shipment module and i want to change the description for to show user how many days your shopping will arrive.

 

I did this function, but isn't works in Prestashop 1.6.13 and 1.7.

public function hookdisplayBeforeCarrier($params)
    {
        if (null == $this->context->cart->getDeliveryOptionList()) {
            return;
        }

        $mercado_envios_activate = Configuration::get('MERCADOENVIOS_ACTIVATE');
        if (empty($mercado_envios_activate) ||
            $mercado_envios_activate == "false") {
            return;
        }

        // Init var
        $address = new Address($params['cart']->id_address_delivery);
        $lista_shipping = (array) Tools::jsonDecode(
            Configuration::get('MERCADOPAGO_CARRIER'),
            true
        );

        $delivery_option_list = $this->context->cart->getDeliveryOptionList();
        $retornoCalculadora = $this->calculateListCache($address->postcode);

        $mpCarrier = $lista_shipping['MP_SHIPPING'];

        foreach ($delivery_option_list as $id_address) {
            foreach ($id_address as $key) {
                foreach ($key['carrier_list'] as $id_carrier) {
                    if (in_array($id_carrier['instance']->id, $mpCarrier)) {
                        if (isset($lista_shipping['MP_CARRIER'][(int)$id_carrier['instance']->id])) {
                            $id_mercadoenvios_service_code = $lista_shipping['MP_CARRIER'][$id_carrier['instance']->id];
                            $calculadora = $retornoCalculadora[(string) $id_mercadoenvios_service_code];
                            $msg = $calculadora['estimated_delivery'].' '.$this->l('working days.');

                            $id_carrier['instance']->delay[$this->context->cart->id_lang] =
                                $this->l('After the post, receive the product ').$msg;
                        }
                    }
                }
            }
        }
    }

The result is:

https://drive.google.com/file/d/0B2DsLG3vEqKAc0dkYTR3YnFhMW8/view?usp=sharing

 

 

I apprenciate any help.

 

Thank you

 

 

 

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...