skip to Main Content

my gateway name is ( Woocommerce_Add_ZarinPal_Gateway )

i want update title this gateway from code

and this my code

$my_options = get_option('woocommerce_WC_ZPal_settings');
 
$my_options['woocommerce_WC_ZPal_settings']['title'] = 'test';
 
update_option('woocommerce_WC_ZPal_settings', $my_options);

but when i update gateway other option with same name is update / not update plugin gateway name

my update output :

woocommerce_WC_ZPal_settings";a:2:{s:5:"title";s:4:"test"}

orginal plugin output :

woocommerce_WC_ZPal_settings" string(793) "a:11:{s:11:"base_config";s:0:"";s:7:"enabled";s:3:"yes";s:5:"title";s:35:"پرداخت امن زرین پال";}

note : i have two ((woocommerce_WC_ZPal_settings)) option with same
name ! why?

3

Answers


  1. Chosen as BEST ANSWER

    i found problem , thanks @Pugazhenthi Murugesan .

    when i want to update gateway method name from code just must use .

    $my_options['title'] = 'test';
     
    update_option('woocommerce_bankmellat_settings', $my_options);


  2. No need to access the woocommerce_WC_ZPal_settings in the my_options array.

    $my_options = get_option('woocommerce_WC_ZPal_settings');
    
    $my_options ['title'] = 'test';
     
    update_option('woocommerce_WC_ZPal_settings', $my_options);
    
    Login or Signup to reply.
  3. You should try to find the specific option name that corresponds to the gateway title you want to update

    $option_name = 'woocommerce_Add_ZarinPal_Gateway_settings';
    $my_options = get_option($option_name);
    $my_options['title'] = 'test';
    update_option($option_name, $my_options);
    

    it should update the gateway title for the specific option that you are targeting.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search