سلام . من میخوام این دو امکان را در ووکامرس قرار بدم چه جوری میشه این کارارو کرد
۱) نمایش میزان تخفیف هر کالا ( برای محصولات متغییر ) مثل عکس زیر ( sam.png)
۲) در محصولات متغییر که قراره قیمت یا توجه به رنگ و مدل یک محصول تغییر کنه فقط یک قیمت رو نشون بده مثل سایت زیر
لینک ها تنها برای اعضای سایت قابل نمایش است.
ولی تو ووکامرس دو تا قیمت نشون میده مثل سایت زیر
لینک ها تنها برای اعضای سایت قابل نمایش است.
تشکر
سلام افزونه زیر کارش همینه ولی برای متغییر ها کار نمیکنه . دلیلش هم قیمت های متفاوت متغییر ها هست . کدام یکی را باید نشون بده ؟
لینک ها تنها برای اعضای سایت قابل نمایش است.
افزونه ی
لینک ها تنها برای اعضای سایت قابل نمایش است.
این کد را هم داخل فایل فانکشن قالبتون قرار بدید و تست کنید :
add_filter('woocommerce_variation_sale_price_html','adventure_tours_sales_price', 10, 2 );
add_filter('woocommerce_sale_price_html','adventure_tours_sales_price', 10, 2 );
function adventure_tours_sales_price( $price, $product ){
// Variables initialisation
$regular_price = $product->regular_price;
$sale_price = $product->sale_price;
$save_text = __('Save', 'woocommerce') . ' ';
if(!empty($sale_price)) {
// Percentage calculation
$percentage = '<span class="save-percent"> ' .$save_text . round( ( ( $regular_price - $sale_price ) / $regular_price ) * 100 ) . '%</span>';
$price = '<del class="strike">' . woocommerce_price( $regular_price ) . '</del>
<ins class="highlight">' . woocommerce_price( $sale_price ) . $percentage . '</ins>';
} else {
$price = '<ins class="highlight">'.woocommerce_price( $regular_price ).'</ins>';
}
return $price;
}
add_filter('woocommerce_variable_sale_price_html', 'adventure_tours_sales_min_max_prices', 20, 2);
function adventure_tours_sales_min_max_prices( $price, $product) {
// Variables initialisation
$variation_min_reg_price = $product->get_variation_regular_price('min', true);
$variation_max_reg_price = $product->get_variation_regular_price('max', true);
$variation_min_sale_price = $product->get_variation_sale_price('min', true);
$variation_max_sale_price = $product->get_variation_sale_price('max', true);
$percentage_min = '';
$percentage_max = '';
$save_text = __('Save', 'woocommerce') . ' ';
// Percentage calculations
if($variation_min_reg_price != $variation_min_sale_price)
$percentage_min = '<span class="save-percent-min"> (' .$save_text . round( ( ( $variation_min_reg_price - $variation_min_sale_price ) / $variation_min_reg_price ) * 100 ) . '%)</span>';
if($variation_max_reg_price != $variation_max_sale_price)
$percentage_max = '<span class="save-percent-max"> (' .$save_text . round( ( ( $variation_max_reg_price - $variation_max_sale_price ) / $variation_max_reg_price ) * 100 ) . '%)</span>';
if (($variation_min_reg_price != $variation_min_sale_price) || ($variation_max_reg_price != $variation_max_sale_price)) {
$price = '<del class="strike">' . woocommerce_price($variation_min_reg_price) . '-' . woocommerce_price($variation_max_reg_price) . '</del>
<ins class="highlight">' . woocommerce_price($variation_min_sale_price) . $percentage_min . ' - ' . woocommerce_price($variation_max_sale_price) . $percentage_max . '</ins>';
}
return $price;
}
خروجی به این شکل باید بده :
در مورد سوال دوم با کدی که سجاد عزیز در این تاپیک دادند می تونید این کار را انجام بدید .
You must be registered for see images attach
You must be registered for see images attach