Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Function Hook - Shippings_Get_Shippings_List_Post Rate Topic   - - - - -

 
  • siarlis
  • Junior Member
  • Members
  • Join Date: 26-Feb 10
  • 2 posts

Posted 06 February 2018 - 01:10 PM #1

I am trying to create a simple modification that will remove a specific shipping method from the list when the customers country is not US. 

 

I have test it the code directly into app/tygh/shippings.php and it works perfect. 

 

Code inside function getShippingsList in file shippings.php

        if ($group["package_info_full"]["location"]["country"] == "US"){
            unset($shippings_info[1]); 
        }    

The problem is when i created this as an addon. The value 1 in shippings_info array is not removed.

 

Addon Code: 

 

File init.php

<?php
 if ( !defined('BOOTSTRAP') ) { die('Access denied'); }
    fn_register_hooks(
        'shippings_get_shippings_list_post'
    );
?>

File Func.php 

<?php
    if ( !defined('BOOTSTRAP') ) { die('Access denied'); }

      function fn_w2g_mod_shipping_shippings_get_shippings_list_post($group, $lang, $area, $shippings_info){
       
        if ($group["package_info_full"]["location"]["country"] == "US"){
            unset($shippings_info[1]); 
        }    
      
          
      }
?>


 

 

The addon works and i can installed though admin.

Also when i print out the $shippings_info array inside the hook function the shipping method has been removed.

 

But it continues to show the shipping method at the checkout page. 

 

Thank you for your time



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 16,431 posts

Posted 06 February 2018 - 01:19 PM #2

Replace

function fn_w2g_mod_shipping_shippings_get_shippings_list_post($group, $lang, $area, $shippings_info){

with

function fn_w2g_mod_shipping_shippings_get_shippings_list_post($group, $lang, $area, &$shippings_info){

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия

 
  • siarlis
  • Junior Member
  • Members
  • Join Date: 26-Feb 10
  • 2 posts

Posted 06 February 2018 - 01:24 PM #3

! Thank you eComLabs . I've totally missed the variable reference ... 



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 16,431 posts

Posted 07 February 2018 - 05:29 AM #4

You are welcome! :)


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration

Certified CS-Cart RU Developer | Сертифицированный разработчик на CS-Cart Русская Версия