Bu, tüm WooCommerce ve Ürün Satıcısı uzantısıyla ilgilidir.WooCommerce Ürün Satıcısı - güncelleştirme taksonomisi özel alanlarını güncelleştir
Fonksiyonumda, yerçekimi formum her gönderiminde yeni taksonomi şartları (Ürün Satıcısı) oluşturuyorum, ancak doldurmak istediğim özel alanlar var.
Aşağıdakiler, ismin ve sümüklü bilginin güncellenmesi için çalışır. PayPal e-postası, Satıcı logosu vb. Gibi alanları güncellemeye çalışıyorum.
Bu test için aşağıdaki değişkenleri elle ayarlıyorum.
$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);
Bu işlev form gönderildiğinde çalışır, yalnızca satıcı taksonomisi alanlarına veri eklemez.
Tam Kod
//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);
nasıl spec olduğunu biliyor muydun Örneğin, kullanmanız gereken 'profil', örneğin 'vendor_profile' ya da bir şey tahmin etmiş olabilirim. – JordanC26