5
這是關於WooCommerce和產品供應商擴展的全部內容。WooCommerce產品供應商 - 更新分類定製字段
在我的函數中,我創建了新的分類術語(產品供應商),每次我的重力形式被提交,但是還有其他的自定義字段,我想填充。
以下工作更新術語名稱和slu。。我試圖更新字段,如貝寶電子郵件,供應商標誌等
對於此測試,我已經手動設置下面的變量。
$user = 'formname';
$email = '[email protected]';
$description = 'this is a test';
$return = wp_insert_term(
$user, // the term
'wcpv_product_vendors', // the taxonomy
array(
'description'=> $description,
'slug' => $user,
)
);
// Update vendor data
$vendor_data['paypal_email'] = $email; // The email used for the account will be used for the payments
$vendor_data['commission'] = '50'; // The commission is 50% for each order
update_option('shop_vendor_' . $return['term_id'], $vendor_data);
// Update vendor data
$vendor_data['paypal_email'] = $email; // The email used for the account will be used for the payments
$vendor_data['commission'] = '50'; // The commission is 50% for each order
$vendor_data['admins'][] = $customer_id; // The registered account is also the admin of the vendor
update_option('shop_vendor_' . $return['term_id'], $vendor_data);
該函數在提交表單時運行,它不會將數據添加到供應商分類標記字段中。
全碼
//Woocommerce - ETSY - Import
function create_vendor_form($entry, $form) {
//////////////////////////////////////////////////////////////////////////// GET DATA FROM API
$user = rgar($entry, '1');
$email = rgar($entry, '2');
$description = rgar($entry, '3');
$return = wp_insert_term(
$user, // the term
'wcpv_product_vendors', // the taxonomy
array(
'description'=> $description,
'slug' => $user,
)
);
// Update vendor data
$vendor_data['paypal_email'] = $email; // The email used for the account will be used for the payments
$vendor_data['commission'] = '50'; // The commission is 50% for each order
$vendor_data['admins'][] = $customer_id; // The registered account is also the admin of the vendor
update_option('shop_vendor_' . $return['term_id'], $vendor_data);
////////////////////////////////////////////////////////// end GET DATA FROM API
}
add_action('gform_after_submission_2', 'create_vendor_form', 10, 2);
如何你知道這是規格嗎?如果你需要使用'profile',例如我可能猜到'vendor_profile'或其他東西。 – JordanC26