以编程方式创建的产品未显示在商店页面上

时间:2021-05-10 06:23:45

标签: php mysql wordpress woocommerce product

它显示在搜索下拉菜单中,但未显示在商店页面上。这些所有产品细节已经完美地保存在数据库中。有时当我从管理面板更改该产品的某些内容并保存它时,它就会在那个时候工作

$post = array(
        'post_author' => $vendor_id,
        'post_content' => str_replace(array("'", "\""), "", strip_tags($product['description'])),
        'post_status' => "publish",
        'post_title' => $product['product_title'],
        'post_parent' => '',
        'post_type' => "product",
    );
update_post_meta( $post_id, '_downloadable', 'no');
update_post_meta( $post_id, '_virtual', 'no');
update_post_meta( $post_id, '_regular_price', $product['regular_price'] );
update_post_meta( $post_id, '_is_new', 'yes' );
update_post_meta( $post_id, '_sku', $product['product_id']);
update_post_meta( $post_id, '_price', $product['regular_price'] );
update_post_meta( $post_id, '_sold_individually', "yes" );
update_post_meta( $post_id, '_manage_stock', "yes" );
update_post_meta( $post_id, '_stock_status', wc_clean( $product['stock_status'] ) );
wp_set_post_terms( $post_id, 'outofstock', 'product_visibility', false );
update_post_meta( $post_id, '_backorders', "no" );
update_post_meta( $post_id, '_stock', $product['quantity'] );
update_post_meta( $post_id, '_ebay_user_id', $ebay_user_id );
update_post_meta( $post_id, '_download_limit', '-1');
update_post_meta( $post_id, '_download_expiry', '-1');
update_post_meta( $post_id, '_product_version', WC_VERSION );
wc_delete_product_transients( $post_id );

0 个答案:

没有答案
相关问题