简体   繁体   English

将woocommerce产品插入为外部/会员类型

[英]Insert woocommerce product as External / Affiliate type

I want to post woocommerce product in wordpress but i wanted this product to be posted as External/Affiliate product. 我想在WordPress中发布woocommerce产品,但我希望将此产品发布为外部/会员产品。 From this link i found a solution that [ wp_set_object_terms( $post_id, 8, 'product_type', false ); 这个链接中,我找到了一个解决方案[wp_set_object_terms($ post_id,8,'product_type',false); ] this code to be used to set it as External/Affiliate product But i need to know then where this code to be put then? ]此代码用于将其设置为外部/会员产品,但我需要知道然后将该代码放在哪里?

require_once("../wp-load.php");


$new_post = array(
    'post_title' => "Title of My Product",
    'post_content' => 'Full description of My Product',
    'post_status' => 'publish',
    'post_type' => 'product',
    'is_visible' => '1'
);

$post_id = wp_insert_post($new_post);
update_post_meta($post_id, '_sku', '5000' );
update_post_meta($post_id, '_regular_price' , '99.95');
update_post_meta($post_id, '_product_url' , 'http://www.google.com');
update_post_meta($post_id, '_button_text' , 'Buyit' );
update_post_meta($post_id, '_aioseop_description' , 'Short description of My Product' );
update_post_meta($post_id, '_visibility' , 'visible' );

她是解决方案:

wp_set_object_terms( $post_id, 'external', 'product_type');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM