반응형
WooCommerce 제품 공급업체 - 분류법 사용자 정의 필드 업데이트
이것은 모두 WooCommerce와 제품 공급업체 확장에 관한 것입니다.
제 기능상 중력 양식이 제출될 때마다 새로운 분류법 용어(제품 공급업체)를 만들고 있지만, 추가로 입력할 사용자 지정 필드가 있습니다.
다음은 용어 이름 및 슬래그를 업데이트하는 작업입니다.페이팔 이메일, 벤더 로고 등의 필드를 업데이트하려고 합니다.
이 테스트를 위해 아래 변수를 수동으로 설정했습니다.
$user = 'formname';
$email = 'example@gmail.com';
$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_data 어레이에 추가한 다음 다음을 사용하여 적용합니다.
//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);
언급URL : https://stackoverflow.com/questions/39747713/woocommerce-product-vendors-update-taxonomy-custom-fields
반응형
'programing' 카테고리의 다른 글
정수(0)를 잡는 방법은? (0) | 2023.07.16 |
---|---|
data.tables의 X[Y] join이 전체 외부 join 또는 왼쪽 join을 허용하지 않는 이유는 무엇입니까? (0) | 2023.07.16 |
GitHub - gitHub 443 창에 연결하지 못함/ gitHub에 연결하지 못함 - 오류 없음 (0) | 2023.07.16 |
여러 GROUP BY가 포함된 전체 요약 (0) | 2023.07.16 |
유형 스크립트로 Angular2 버전을 확인하는 방법 (0) | 2023.07.16 |