2016-09-28 24 views
5

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.

enter image description here

enter image description here

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); 

cevap

2

Önce $ vendor_data diziye veri eklemek ve sonra kullanarak aşağıdaki uygulama:

//Add the data to the array 
$vendor_data['paypal'] = $email; 
$vendor_data['profile'] = $description; 

//Update the term meta with the above values. 
update_term_meta($return['term_id'], 'vendor_data', $vendor_data); 
+0

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

İlgili konular