Jump to content

id_carrier not correctly updating in One page checkout.


chinthaka

Recommended Posts

I have installed cash on delivery on my shopping cart. And I want it to enable only for local addresses. So I have added a hook displayPayment on the cash on delivery module and in that I check the local carrier, If it's not the local carrier need to hide the cash on delivery option from the payment options list. I'm doing that using the id_carrier property, but it won't update according to the delivery address. I'm using One page checkout in my cart.

 

here is how my displayPayment hook looks.

$smarty->assign(array(
               'this_path' => $this->_path,
               'cartcost' => number_format(floatval( $cartcost ), 2, '.', ''),
               'fee' => number_format(floatval( $fee ), 2, '.', ''),
               'minimum_amount' => number_format(floatval( $minimum_amount ), 2, '.', ''),
               'maximum_amount' => number_format(floatval( $maximum_amount ), 2, '.', ''),
               'shippingcost' => number_format(floatval($shippingcost), 2, '.', ''),
               'total' => number_format(floatval( $total ), 2, '.', ''),
               'carriers_array' => $id_carriers_selected_array,
               'carrier_selected' => $params['cart']->id_carrier,
               'this_path_ssl' => (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://').htmlspecialchars($_SERVER['HTTP_HOST'], ENT_COMPAT, 'UTF-8').__PS_BASE_URI__.'modules/'.$this->name.'/'
               ));
        return $this->display(__FILE__,'views/payment.tpl');

Here i'm getting the wrong value for 'carrier_selected'

 

below is how I check local carrier in payment.tpl

{assign var='carrier_ok' value='nok'}
{foreach $carriers_array as $carrier_array}
    {if $carrier_selected == $carrier_array}
        {$carrier_ok = 'ok'}
        {break}
    {/if}
{/foreach}

Please help on this.

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...