I’m looking for a way to display (optional) sale prices, if a vendor adds a product. So also a normal price if the product is not on sale.
How can I incorporate all of this:
update_post_meta( $new_submission_id, '_price', $price );
update_post_meta( $new_submission_id, '_regular_price', $regular_price );
update_post_meta( $new_submission_id, '_sale_price', $sale_price );
update_post_meta( $new_submission_id, '_sale_price_dates_from', '' );
update_post_meta( $new_submission_id, '_sale_price_dates_to', '' );
In this:
// Add prices to WooCommerce products
add_action( 'gform_advancedpostcreation_post_after_creation', 'update_product_information', 10, 4 );
function update_product_information( $post_id, $feed, $entry, $form ){
//update the prices set for the product
update_post_meta( $post_id, '_regular_price', $entry['26'] );
update_post_meta( $post_id, '_price', $entry['26'] );
}
I’ve been fiddling around with ‘if’ and ‘elseif’, but I keep getting errors.