• Resolved elmersw

    (@elmersw)


    I’m getting the following error when testing as a new (not logged-in) user. I added 1 item to the cart and went straight to the cart page.

    Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\speciaalbierwebshop\wp-content\plugins\wt-smart-coupons-for-woocommerce\public\class-wt-smart-coupon-public.php

    The particular line of code:
    $chosen_shipping = $chosen_shipping_methods[0];

    I suspect the error is thrown as no shipping method has been selected yet. I have set Woocommerce to hide shipping cost until an address has been input. No customized code, just the regular shipping option.

    I have solved this temporarily by adding an if statement.

    if ( isset($chosen_shipping_methods[0])) {
    $chosen_shipping = $chosen_shipping_methods[0];
    $chosen_shipping = substr($chosen_shipping, 0, strpos($chosen_shipping, “:”));
    if (!in_array($chosen_shipping, $coupon_shipping_method_ids)) {
    $valid = false;
    }

    if ( ! $valid ) {
    throw new Exception( __( ‘Sorry, this coupon is not applicable to selected shipping method’, ‘wt-smart-coupons-for-woocommerce’ ), 109 );
    }
    }
    }`

Viewing 1 replies (of 1 total)
  • Plugin Author WebToffee

    (@webtoffee)

    Hi @elmersw,

    Thanks for reaching out.

    We have identified the issue and will fix it in our upcoming release this week. Thanks for pointing it out. We count on your continued support of our plugins. Feel free to write to us if any further queries. Always happy to help.

Viewing 1 replies (of 1 total)
  • The topic ‘Trying to access array offset on value of type null’ is closed to new replies.