Hot

الخميس، 18 يونيو 2015

Generate Product Description for WooCommerce Bulk Discount

Generate Product Description for WooCommerce Bulk Discount Automaticaly with this function

1- Copy the function into functions.php file.
2- then paste "echo bulk();" in "your-template\woocommerce\single-product\meta.php"


function bulk(){
if(is_single()){
global $post, $product;
if ( get_post_meta($product->id , '_bulkdiscount_quantity_1', true) ) : 
$bulk1 = get_post_meta($product->id , '_bulkdiscount_quantity_1', true);
$bulk11 = get_post_meta($product->id , '_bulkdiscount_discount_1', true);
$bq=floatval($bulk1);
$bd=floatval($bulk11);
$price = get_post_meta($product->id , '_price', true);
$p=floatval($price);
$newprice = round($p - ( $p * ( $bd /100)), 2);
$np=(string)$newprice;
echo "Buy ".$bulk1." for € ".$np." each and Save ".$bulk11."%.

";
endif;
if ( get_post_meta($product->id , '_bulkdiscount_quantity_2', true) ) : 
$bulk1 = get_post_meta($product->id , '_bulkdiscount_quantity_2', true);
$bulk11 = get_post_meta($product->id , '_bulkdiscount_discount_2', true);
$bq=floatval($bulk1);
$bd=floatval($bulk11);
$price = get_post_meta($product->id , '_price', true);
$p=floatval($price);
$newprice = round($p - ( $p * ( $bd /100)), 2);
$np=(string)$newprice;
echo "Buy ".$bulk1." for € ".$np." each and Save ".$bulk11."%.

";
endif;
if ( get_post_meta($product->id , '_bulkdiscount_quantity_3', true) ) : 
$bulk1 = get_post_meta($product->id , '_bulkdiscount_quantity_3', true);
$bulk11 = get_post_meta($product->id , '_bulkdiscount_discount_3', true);
$bq=floatval($bulk1);
$bd=floatval($bulk11);
$price = get_post_meta($product->id , '_price', true);
$p=floatval($price);
$newprice = round($p - ( $p * ( $bd /100)), 2);
$np=(string)$newprice;
echo "Buy ".$bulk1." for € ".$np." each and Save ".$bulk11."%.";
endif;
}
}

ليست هناك تعليقات:

إرسال تعليق