Support » Plugin: WooCommerce » Sale price showing but not regular price after adding product

  • Hi there,

    I am trying to add a product programmatically ( with woocommerce api calls) by creating a function called cre_prod() in cleansale functions.php


    function cre_prod() {
    $post = array(

    ‘post_author’ => ‘1’,

    ‘post_content’ => ‘blah text’,

    ‘post_status’ => “publish”,

    ‘post_title’ => ‘blah name’,

    // ‘post_parent’ => $product->parent_id,

    ‘post_type’ => “product” );

    //Create post

    $wp_error=’; $post_id = wp_insert_post( $post, $wp_error );

    wp_set_object_terms( $post_id, array( ‘perfumes’), ‘product_cat’ );

    wp_set_object_terms($post_id, ‘simple’, ‘product_type’);

    update_post_meta($post_id, ‘_sku’, ‘skuu123’);

    update_post_meta( $post_id, ‘_regular_price’, 2.22 );

    update_post_meta( $post_id, ‘_price’, 3.33);

    update_post_meta( $post_id, ‘_visibility’, ‘visible’ );

    update_post_meta( $post_id, ‘_stock_status’, ‘instock’);

    update_post_meta( $post_id, ‘_stock_qty’, ‘789’);

    return ‘ok’;}


    return $wp_error;

    }add_shortcode( ‘cre_prod’ );


    After calling cre_prod(), the added product indeed shows up at wp dashboard as well as site ( under category Perfumes).

    The problem I am facing is that

    Regular price of 2.22 shows up correcly in wp dashboard but is not showing up on site.

    Sale price of 3.33 shows up correcly on site but is blank at wp dashboard.

    Could u advise? Any help/pointer would be greatly appreciated.


  • The topic ‘Sale price showing but not regular price after adding product’ is closed to new replies.