5
이것은 모두 WooCommerce 및 제품 공급 업체 확장에 관한 것입니다.WooCommerce 제품 공급 업체 - 분류학 사용자 지정 필드 업데이트
내 함수에서 중력 양식이 제출 될 때마다 새 분류학 용어 (제품 공급 업체)를 만들지 만 채울 사용자 지정 필드가 추가로 있습니다.
다음은 용어 이름과 슬러그를 업데이트하는 방법입니다. PayPal 이메일, 공급 업체 로고 등의 필드를 업데이트하려고합니다.
이 테스트에서는 아래 변수를 수동으로 설정했습니다.
$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);
어떻게 그게 스펙인지 알았 니? 예를 들어 'vendor_profile'또는 뭔가를 추측했을 수 있습니다. – JordanC26