5
これは、WooCommerceとProduct Vendor拡張に関するものです。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