Đây là tất cả liên quan đến phần mở rộng WooCommerce và Nhà cung cấp sản phẩm.Nhà cung cấp sản phẩm WooCommerce - cập nhật các trường tùy chỉnh phân loại
Trong chức năng của mình, tôi đang tạo các thuật ngữ phân loại mới (Nhà cung cấp sản phẩm) mỗi khi biểu mẫu trọng lực của tôi được gửi, tuy nhiên có thêm trường tùy chỉnh mà tôi muốn điền.
Các công trình sau đây để cập nhật tên và sên. Tôi đang cố cập nhật các trường như email PayPal, Biểu trưng của nhà cung cấp, v.v.
Để kiểm tra này, tôi đã đặt thủ công các biến bên dưới.
$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);
Hàm chạy khi biểu mẫu được gửi, nó không chỉ thêm dữ liệu vào trường phân loại nhà cung cấp.
Full Mã
//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);
thế nào bạn có biết đó là thông số ifically 'profile' bạn cần sử dụng, ví dụ tôi có thể đoán 'vendor_profile' hoặc cái gì đó. – JordanC26