WordPress.org

Forums

WooCommerce - excelling eCommerce
Sale price showing but not regular price after adding product (1 post)

  1. vickers
    Member
    Posted 1 year ago #

    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 );

    if($post_id){
    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';}

    else{

    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.

    tks,
    newbie

    http://wordpress.org/plugins/woocommerce/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic