• Resolved adamleese

    (@adamleese)


    Hi

    I’m doing an import to update information on existing WooCommerce products, at the same time I’d like to perform some maths to the current prices (but my spreadsheet doesn’t contain the current price info).

    I wonder if there’s a way to perform maths on the current price (e.g. the price currently stored in _regular_price and _price).

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author WP All Import

    (@wpallimport)

    Hi @adamleese,

    I wonder if there’s a way to perform maths on the current price (e.g. the price currently stored in _regular_price and _price).

    You could use custom code and our API to do that: http://www.wpallimport.com/documentation/developers/action-reference/. Here’s an example snippet that you can modify as needed:

    add_action( 'pmxi_saved_post', 'my_update_price', 10, 3 );
    
    function my_update_price( $product_id, $import_record_data, $is_update ) {
    	$product = wc_get_product( $product_id );
    	if ( ! $product ) return;
    	
    	$current_price = $product->get_price();
    	$current_regular_price = $product->get_regular_price();
    	// Do something with the price.
    }
    Plugin Author WP All Import

    (@wpallimport)

    Hi @adamleese,

    I’m marking this as resolved since it’s been inactive for a while. Feel free to follow up here if you still have questions.

    Anyone else, please open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Using the currently stored price’ is closed to new replies.