دارکوب کالا
تازه وارد
سلام . کد زیر میاد میزان سود در یک خرید رو نشون میده ( مثلا اگه جنسی ۳۰۰ باشه تخفیف بخوره بشه ۲۹۰ کد زیر میزنه سود شما ۱۰ تومن )
حالا میخوام همین میزان سود رو بعد از قیمت در صفحه محصولات نشون بده
function bbloomer_wc_discount_total() {
global $woocommerce;
$discount_total = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values) {
$_product = $values['data'];
if ( $_product->is_on_sale() ) {
$discount = ($_product->regular_price - $_product->sale_price) * $values['quantity'];
$discount_total += $discount;
}
}
if ( $discount_total > 0 ) {
echo '<tr class="cart-discount">
<th>'. __( 'ذخیره شما', 'woocommerce' ) .'</th>
<td data-title=" '. __( 'ذخیره شما', 'woocommerce' ) .' ">'
. wc_price( $discount_total + $woocommerce->cart->discount_cart ) .'</td>
</tr>';
}
}
// Hook our values to the Basket and Checkout pages
add_action( 'woocommerce_cart_totals_after_order_total', 'bbloomer_wc_discount_total', 99);
add_action( 'woocommerce_review_order_after_order_total', 'bbloomer_wc_discount_total', 99);
تشکر
حالا میخوام همین میزان سود رو بعد از قیمت در صفحه محصولات نشون بده
function bbloomer_wc_discount_total() {
global $woocommerce;
$discount_total = 0;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values) {
$_product = $values['data'];
if ( $_product->is_on_sale() ) {
$discount = ($_product->regular_price - $_product->sale_price) * $values['quantity'];
$discount_total += $discount;
}
}
if ( $discount_total > 0 ) {
echo '<tr class="cart-discount">
<th>'. __( 'ذخیره شما', 'woocommerce' ) .'</th>
<td data-title=" '. __( 'ذخیره شما', 'woocommerce' ) .' ">'
. wc_price( $discount_total + $woocommerce->cart->discount_cart ) .'</td>
</tr>';
}
}
// Hook our values to the Basket and Checkout pages
add_action( 'woocommerce_cart_totals_after_order_total', 'bbloomer_wc_discount_total', 99);
add_action( 'woocommerce_review_order_after_order_total', 'bbloomer_wc_discount_total', 99);
تشکر
آخرین ویرایش توسط مدیر: