Support » Plugin: WC Pickup Store » Some questionable logic in code

  • Resolved martinjts

    (@martinjts)


    Hello,

    Sorry, I couldn’t find a git repo where to post this, so I’ll do it here.

    In your wps-functions.php file you have a function called wps_get_chosen_shipping_method() which is marked as deprecated as per phpdoc. The successor function is_wps_chosen_shipping_method() is noted in the docs, but it literally just uses the same old deprecated function. This is not how deprecation works, you need to revise that logic.

    Also, in the function wps_get_chosen_shipping_method() you have the following code:

    $chosen_methods = WC()->session->get('chosen_shipping_methods');
    return $chosen_methods[0];

    In most cases ‘chosen_shipping_methods’ is empty, so it returns NULL, but your following line tries to parse it like it’s an array. This throws a notice on all pages where this function is called out (product page, adding to cart, cart, checkout, etc). A simple validation for $chosen_methods will fix this. Or just do this:

    return $chosen_methods[0] ?? null;

    Thank you for your attention.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Keylor Mendoza

    (@keylorcr)

    Hey @martinjts

    I really appreciate your comment, I was pretending to set this function as deprecated, but it is in use for an addon of another developer and I’ve forgotten to remove that deprecation.

    It will be fixed in the next release and also I will apply your suggestion for the value that returns.

    Thank you for your support

    Regards.

    Thread Starter martinjts

    (@martinjts)

    @keylorcr Thanks a lot! I appreciate it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Some questionable logic in code’ is closed to new replies.