Home > Software engineering >  An issue in checkout page
An issue in checkout page

Time:12-05

Hi there I have wordpress site , and someone wrote plugin for me , and now when I installed on my website I'm getting this errors on my "checkout" page :

Warning: Illegal string offset 'snumber' in /home/afraa/public_html/wp-content/plugins/avin-customize2/avin-customize.php on line 176

Fatal error: Uncaught Error: Call to undefined method stdClass::get_label() in /home/afraa/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php:354 Stack trace: #0 /home/afraa/public_html/wp-content/themes/zanbil/woocommerce/cart/cart-shipping.php(39): wc_cart_totals_shipping_method_label(Object(stdClass)) #1 /home/afraa/public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('/home/afraa/pub...') #2 /home/afraa/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php(236): wc_get_template('cart/cart-shipp...', Array) #3 /home/afraa/public_html/wp-content/themes/zanbil/woocommerce/cart/cart-totals.php(46): wc_cart_totals_shipping_html() #4 /home/afraa/public_html/wp-content/plugins/woocommerce/includes/wc-core-functions.php(345): include('/home/afraa/pub...') #5 /home/afraa/public_html/wp-content/plugins/woocommerce/includes/wc-template-functions.php(2136): wc_get_template('cart/cart-total...') #6 /home/afraa/public_html/wp-includes/class-wp-hook.php(30 in /home/afraa/public_html/wp-content/plugins/woocommerce/includes/wc-cart-functions.php on line 354

when I checked the lines I didn't get anything wrong , can anyone help me to fix this ?

these are the lines :


    $fields['billing']['billing_s_number'] = array(
        'label' => 'شماره ثبت',
        'required' => false,
        'clear' => false,
        'class' => array('du-none'),
        'type' => 'text',

      this is the line 176 :  'default' => get_user_meta(get_current_user_id(), 'company_data', true)['snumber'] ?: ""

    );

please anyone who know PHP please help me to fix this

CodePudding user response:

get_user_meta(get_current_user_id(), 'company_data', true) don't have snumber key.

Could you try :

isset(get_user_meta(get_current_user_id(), 'company_data', true)['snumber']) ? get_user_meta(get_current_user_id(), 'company_data', true)['snumber']: ""

Regards,

  • Related