رفتن به مطلب

تغییر ماژول تخفیف به کارمزد


kamiar3712

پست های پیشنهاد شده

سلام دوباره دوستان

در وردرپرس و افزونه ووکامرس:

برای بخش کارمزد بنده افزونه تخفیف را woocommerce-bulk-discount به کارمزد تغییر دادم یعنی در بخشی که قرار است بصورت تخفیف مبلغ کسر شود, مبلغ اضافه میشود:


public function filter_cart_product_subtotal( $subtotal, $_product, $quantity ) {

if ( !$_product || !$quantity ) {
return $subtotal;
}
if ( $this->coupon_check() ) {
return $subtotal;
}
if ( get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) != '' && get_post_meta( $_product->id, "_bulkdiscount_enabled", true ) !== 'yes' ) {
return $subtotal;
}

$coeff = $this->discount_coeffs[$this->get_actual_id( $_product )]['coeff'];
if ( ( get_option( 'woocommerce_t4m_discount_type', '' ) == 'flat' ) ) {
$newsubtotal = woocommerce_price( max( 0, ( $_product->get_price() * $quantity ) + $coeff ) );
} else {
$newsubtotal = woocommerce_price( $_product->get_price() * $quantity * $coeff );
}

return $newsubtotal;

همان طور که متوجه شده اید با + $coeff مبلغ اضافه میشود و اتفاقا در صدور

فاکتور در ردیف کالا, مشکلی وجود ندارد و بدرستی کارمزد اضافه میشود اما در

جمع کل سبد خرید دوباره مبلغ کسر میشود و بشکلی که انگار مبلغ کالا به

صورت تخفیف محاسبه شده, بیان میشود.

در تصویر هم مشخص است.

http://s5.picofile.com/file/8147425292/Error.JPG

تقریبا سه تا چهار فایل درگیر هستند که آخرین کدی که به آن رسیدیم بصورت زیر است که در اینجا قرار میدهم:

ابتدا تابع wc_cart_totals_subtotal_html(); :


<tr class="cart-subtotal">
<th><?php _e( 'Cart Subtotal', 'woocommerce' ); ?></th>
<td><?php wc_cart_totals_subtotal_html(); ?></td>

</tr>

و:


function wc_cart_totals_subtotal_html() {
echo WC()->cart->get_cart_subtotal();
}

و در نهایت که فکر میکنم باید در این بخش به دنبال مشکل گشت:


/**
* Gets the sub total (after calculation).
*
* @params bool whether to include compound taxes
* @return string formatted price
*/
public function get_cart_subtotal( $compound = false ) {

// If the cart has compound tax, we want to show the subtotal as
// cart + shipping + non-compound taxes (after discount)
if ( $compound ) {

$cart_subtotal = wc_price( $this->cart_contents_total + $this->shipping_total + $this->get_taxes_total( false, false ) );

// Otherwise we show cart items totals only (before discount)
} else {

// Display varies depending on settings
if ( $this->tax_display_cart == 'excl' ) {

$cart_subtotal = wc_price( $this->subtotal_ex_tax );

if ( $this->tax_total > 0 && $this->prices_include_tax ) {
$cart_subtotal .= ' <small>' . WC()->countries->ex_tax_or_vat() . '</small>';
}

} else {

$cart_subtotal = wc_price( $this->subtotal );

if ( $this->tax_total > 0 && !$this->prices_include_tax ) {
$cart_subtotal .= ' <small>' . WC()->countries->inc_tax_or_vat() . '</small>';
}

}
}

دوستان نظری دارند؟

دوستان نظری دارند؟

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...