Skip to content

Instantly share code, notes, and snippets.

@mahbubme
Last active February 6, 2019 17:58
Show Gist options
  • Save mahbubme/989466b22142d7cba936edfcbf4308a7 to your computer and use it in GitHub Desktop.
Save mahbubme/989466b22142d7cba936edfcbf4308a7 to your computer and use it in GitHub Desktop.
Update product price of WooCommerce based on different conditions
<?php
function update_price_wpuf_form( $post_id ) {
$boolChifre = isset( $_POST['pa_chifre'] ) ? $_POST['pa_chifre'] : 0;
$currentPrice = get_post_meta( $post_id, '_regular_price' );
$images = get_post_meta( $post_id, '_product_image' );
$images = count($images);
if ( $images > 2 ) {
$currentPrice = 35;
}
if( $boolChifre == 62) {
$regular_price = (int)$currentPrice + 10;
}
update_post_meta( $post_id, '_regular_price', $regular_price );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment