Importing into role based price with wp all import

时间:2016-04-07 10:45:42

标签: php wordpress woocommerce

I'm using the woocommerce plugin Role Based Price as we have two extra users thats price will get updated from a csv.

When i import using the WP All Import tool i specify the custom field i want to update with the function but all i get is a NULL value in the table.

Can someone please point out what i'm doing wrong here.

I assumed it was because the data in the manual update is a string and the values trying to import are integer

So in WPALLIMPORT it looks like this under the custom field option

Custom Field                        Value
_role_based_price                   [my_role_pricing({distributor_price[1]},{installer_price[1]})]

Then My Function

function my_role_pricing( $distributor_price, $installer_price ) {
$price_array = array(
    "distributor_customer" => array(
        "regular_price" => $distributor_price
        ),
    "installer_customer" => array(
        "regular_price" => $installer_price
        )
    );
return serialize( $price_array );

}

This is what my CSV looks Like

user_role;Code;regular_price
installer_customer;ProductCode;1000
distributor_customer;ProductCode;1500

The Mysql Table With Manually Set Role Prices Before Import

meta_key: _role_based_price
meta_value: a:2:{s:20:"distributor_customer";a:1:{s:13:"regular_price";s:4:"1100";}s:18:"installer_customer";a:1:{s:13:"regular_price";s:4:"1300";}}

The Mysql Table With Price After Import

meta_key: _role_based_price
meta_value: a:2:{s:20:"distributor_customer";a:1:{s:13:"regular_price";N;}s:18:"installer_customer";a:1:{s:13:"regular_price";N;}}

0 个答案:

没有答案