Page 40 of 40 FirstFirst ... 30383940
Results 391 to 397 of 397
  1. #391
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: Optional Shipping Insurance Module Support Thread...

    Quote Originally Posted by dennisns7d View Post
    To eliminate the warning when using PHP 7+, change
    Code:
    		function ot_insurance() {
    to
    Code:
    		function __construct() {
    OK, but for Zen-cart version 1.5.8, when you replace the function name with __construct() the following errors are given when the Order Total Modules page is visited in the Admin. Evidently it is trying to get an order delivery country which does not exist

    --> PHP Warning: Attempt to read property "delivery" on null in C:\xampp\htdocs\includes\modules\order_total\ot_insurance.php on line 37.
    --> PHP Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\includes\modules\order_total\ot_insurance.php on line 37.

    Line 37 is like this
    PHP Code:
        $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' $i) . "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id"); 
    Any ideas how to overcome this? Should there be an Admin page check?
    Last edited by zamzom; 15 Feb 2023 at 05:45 PM.

  2. #392
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: Optional Shipping Insurance Module Support Thread...

    > Should there be an Admin page check?

    Yep.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  3. #393
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: Optional Shipping Insurance Module Support Thread...

    Quote Originally Posted by swguy View Post
    > Should there be an Admin page check?

    Yep.
    Thank you for the quick response. I was just not sure where to put the control. I am wondering if this is the right place to block out while in the admin section (added if control around ---> // Check if called in admin page):

    PHP Code:
            function __construct() {
                global 
    $order$currencies$db;
                
    $this->code 'ot_insurance';
                
    $this->title MODULE_ORDER_TOTAL_INSURANCE_TITLE;
                
    $this->description MODULE_ORDER_TOTAL_INSURANCE_DESCRIPTION;
                
    $this->enabled = ((MODULE_ORDER_TOTAL_INSURANCE_STATUS == 'true') ? true false);
                
    $this->sort_order MODULE_ORDER_TOTAL_INSURANCE_SORT_ORDER;
                
    $this->credit_class true;
                
    $this->output = array();
                
    $geozones $db->Execute("SELECT * FROM " TABLE_GEO_ZONES);
                
    $this->num_zones $geozones->RecordCount();
                if (!
    defined('IS_ADMIN_FLAG') || (IS_ADMIN_FLAG === false)) {    // Check if called in admin page
                    
    if ($this->enabled == true) {
                        
    $this->dest_zone 0;
                        for (
    $i 1$i <= $this->num_zones$i++) {
                            if ((int) 
    constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' $i) > 0) {
                                
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' $i) . "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id");
                                while (!
    $check->EOF) {
                                    if (
    $check->fields['zone_id'] < 1) {
                                        
    $this->dest_zone $i;
                                        break;
                                    }
                                    elseif (
    $check->fields['zone_id'] == $order->delivery['zone_id']) {
                                        
    $this->dest_zone $i;
                                        break;
                                    }
                                    
    $check->MoveNext();
                                } 
    // end while
                            
    // END if ((int)constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' . $i) > 0)
                        
    // END for ($i=1; $i<=$this->num_zones; $i++)
                        
    if ($this->dest_zone && MODULE_ORDER_TOTAL_INSURANCE_ZONE_1 0) {
                            
    $this->enabled false;
                        }
                    }
                }  
    // Check if called in admin page
            


  4. #394
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: Optional Shipping Insurance Module Support Thread...

    Quote Originally Posted by swguy View Post
    > Should there be an Admin page check?

    Yep.
    Thank you for the quick reply. I was just not sure about where to put the control. Is it OK to block the following segment as it is done with the if block (marked with----> // Check if called in admin page)
    PHP Code:
            function __construct() {
                global 
    $order$currencies$db;
                
    $this->code 'ot_insurance';
                
    $this->title MODULE_ORDER_TOTAL_INSURANCE_TITLE;
                
    $this->description MODULE_ORDER_TOTAL_INSURANCE_DESCRIPTION;
                
    $this->enabled = ((MODULE_ORDER_TOTAL_INSURANCE_STATUS == 'true') ? true false);
                
    $this->sort_order MODULE_ORDER_TOTAL_INSURANCE_SORT_ORDER;
                
    $this->credit_class true;
                
    $this->output = array();
                
    $geozones $db->Execute("SELECT * FROM " TABLE_GEO_ZONES);
                
    $this->num_zones $geozones->RecordCount();
                if (!
    defined('IS_ADMIN_FLAG') || (IS_ADMIN_FLAG === false)) {  // Check if called in admin page
                    
    if ($this->enabled == true) {
                        
    $this->dest_zone 0;
                        for (
    $i 1$i <= $this->num_zones$i++) {
                            if ((int) 
    constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' $i) > 0) {
                                
    $check $db->Execute("select zone_id from " TABLE_ZONES_TO_GEO_ZONES " where geo_zone_id = '" constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' $i) . "' and zone_country_id = '" $order->delivery['country']['id'] . "' order by zone_id");
                                while (!
    $check->EOF) {
                                    if (
    $check->fields['zone_id'] < 1) {
                                        
    $this->dest_zone $i;
                                        break;
                                    }
                                    elseif (
    $check->fields['zone_id'] == $order->delivery['zone_id']) {
                                        
    $this->dest_zone $i;
                                        break;
                                    }
                                    
    $check->MoveNext();
                                } 
    // end while
                            
    // END if ((int)constant('MODULE_ORDER_TOTAL_INSURANCE_ZONE_' . $i) > 0)
                        
    // END for ($i=1; $i<=$this->num_zones; $i++)
                        
    if ($this->dest_zone && MODULE_ORDER_TOTAL_INSURANCE_ZONE_1 0) {
                            
    $this->enabled false;
                        }
                    }
                }  
    // Check if called in admin page
            


  5. #395
    Join Date
    Jun 2009
    Location
    Europe
    Posts
    58
    Plugin Contributions
    1

    Default Re: Optional Shipping Insurance Module Support Thread...

    In ot_insurance.php (version 3.2.4) around line 245:

    PHP Code:
                $selected = ((isset($_SESSION['opt_insurance']) && $_SESSION['opt_insurance'] == '1') ? true false);
                
    $display_insurance true;
                if ((
    $order_total_insurance >= MODULE_ORDER_TOTAL_INSURANCE_REQUIRED) || (($order_total_insurance <= MODULE_ORDER_TOTAL_INSURANCE_OVER) && (MODULE_ORDER_TOTAL_INSURANCE_OVER 0) && ($order_total_insurance >= MODULE_ORDER_TOTAL_INSURANCE_REQUIRED))) {
                    
    $display_insurance false;
                } 
    What is the meaning of this if control?
    Susbtituting with simple letters here is the simplified logic function:
    (Let's say a is the upper limit and set to 10000, b is the lower limit and set to 100)
    ((ins>= a) || ((ins<=b) && (b>0) && (ins>=a)))
    if ins>=a first part of the or function is fulfilled and result is true
    if ins<a first part of or function valued false and the second part may never be true.
    so mathematically this is equivalent of making only this logic control:
    ins>=a

    Am I missing something?

  6. #396
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: Optional Shipping Insurance Module Support Thread...

    Yeah it looks wrong to me too.
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

  7. #397
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    9,684
    Plugin Contributions
    123

    Default Re: Optional Shipping Insurance Module Support Thread...

    @zamzom, this module hasn't been updated in a long time - perhaps you'd like to adopt it and make improvements?

    https://docs.zen-cart.com/dev/plugins/adoption/
    That Software Guy. My Store: Zen Cart Modifications
    Available for hire - See my ad in Services
    Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
    Do you benefit from Zen Cart? Then please support the project.

 

 
Page 40 of 40 FirstFirst ... 30383940

Similar Threads

  1. Optional Shipping Insurance Module Question
    By kminnich in forum Built-in Shipping and Payment Modules
    Replies: 0
    Last Post: 7 Oct 2008, 01:16 AM
  2. Optional Shipping Insurance Module
    By Darkwander in forum Addon Shipping Modules
    Replies: 2
    Last Post: 9 Oct 2006, 02:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR