Home

Friday, January 23, 2015

How to add product in woocommerce using programmatically with wpml

function woocommerce_add_products_dynamicaly()
 {
        //empty cart
        global $woocommerce;
        $woocommerce->cart->empty_cart();
        // Remove default cart message
        $woocommerce->clear_messages();
       
        //price
        $invoiceprice = 1;
       
        //Generate title
        $timestampedtitle = rand()." Date: ".date("d/m/Y")." Amount: £".$invoiceprice;
       
        //Generate message
        $message = date_timestamp_get(date_create())." Date: ".date('m/d/Y h:i:s a', time())." Invoice amount: £".$invoiceprice;

        $post = array(
        'post_author' => '2',
        'post_status' => "publish",
        'post_title' => $timestampedtitle,
        'post_content' => $message,
        'post_parent' => '',
        'post_type' => "product",
        //'post_status' => 'private',
        );

rathoddhirendra.blogspot.com-Google pagerank and Worth