Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2017
    Location
    West Midlands, UK
    Posts
    40
    Plugin Contributions
    0

    Default UK shipping by postcode error logs

    Hi,
    I have installed the UK shipping by postcode module (on ZenCart 2.1.0 using PHP 8.3).

    When viewing the shopping cart, a couple of PHP logs are generated due to the delivery postcode not being available/entered yet. The shipping estimator successfully displays at the bottom of the page, but the following logs are generated:

    Code:
    --> PHP Warning: Undefined array key "postcode" in ……../includes/modules/shipping/ukpost.php on line 178.
    
    
    --> PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in ……../includes/modules/shipping/ukpost.php on line 179.

    Please see below lines 178 and 179 of ukpost.php

    Code:
            $destination_postcode = $order->delivery['postcode'];
      	  $pcode = preg_replace('/\s\s*/', '', $destination_postcode);

    The errors are only generated if a postcode has not been entered. Any help with this issue would be much appreciated.
    Rick

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,378
    Plugin Contributions
    94

    Default Re: UK shipping by postcode error logs

    Quote Originally Posted by richard7315 View Post
    Hi,
    I have installed the UK shipping by postcode module (on ZenCart 2.1.0 using PHP 8.3).

    When viewing the shopping cart, a couple of PHP logs are generated due to the delivery postcode not being available/entered yet. The shipping estimator successfully displays at the bottom of the page, but the following logs are generated:

    Code:
    --> PHP Warning: Undefined array key "postcode" in ……../includes/modules/shipping/ukpost.php on line 178.
    
    
    --> PHP Deprecated: preg_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated in ……../includes/modules/shipping/ukpost.php on line 179.

    Please see below lines 178 and 179 of ukpost.php

    Code:
            $destination_postcode = $order->delivery['postcode'];
            $pcode = preg_replace('/\s\s*/', '', $destination_postcode);

    The errors are only generated if a postcode has not been entered. Any help with this issue would be much appreciated.
    Rick
    Make the highlighted change to line 178:
    Code:
            $destination_postcode = $order->delivery['postcode'] ?? '';
            $pcode = preg_replace('/\s\s*/', '', $destination_postcode);

  3. #3
    Join Date
    Jul 2017
    Location
    West Midlands, UK
    Posts
    40
    Plugin Contributions
    0

    Default Re: UK shipping by postcode error logs

    Hi Lat9
    Thank you for your help. The addition of the ?? '' null coalescing operator worked perfectly.
    Many thanks
    Rick

 

 

Similar Threads

  1. UK Shipping by Postcode
    By Z3NN3D in forum Addon Shipping Modules
    Replies: 58
    Last Post: 15 Sep 2022, 04:38 PM
  2. v151 Shipping to postcode in Canada
    By Skyland in forum Addon Shipping Modules
    Replies: 1
    Last Post: 21 Mar 2014, 07:09 PM
  3. Shipping by Postcode
    By billett in forum Built-in Shipping and Payment Modules
    Replies: 3
    Last Post: 6 Oct 2009, 09:31 AM
  4. UK Shipping by postcode
    By schoolboy in forum Built-in Shipping and Payment Modules
    Replies: 14
    Last Post: 29 Mar 2007, 04:13 PM

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