Murat Bütün

WooCommerce Sepete İndirim Toplamı Gösterme

WordPress’in en gelişmiş e-ticaret eklentisi WooCommerce alt yapılı web sitenize müşterilerinizi sitenize yaptığınız indirimleri sepet toplamında göstermek için aşağıdaki kodu temanızın functions.php dosyasına ekleyiniz. Bu sayede müşterinizi sepette ödeme geçme olasılığını arttırmış olursunuz.

// muratbutun.com 
function bbloomer_wc_discount_total()
	{
	global $woocommerce;
	$cart_subtotal = $woocommerce->cart->cart_contents;
	$discount_total = 0;
foreach($woocommerce->cart->cart_contents as $product_data)
		{
if ($product_data['variation_id'] > 0)
			{
			$product = wc_get_product($product_data['variation_id']);
			}
		  else
			{
			$product = wc_get_product($product_data['product_id']);
			}
if (!empty($product->sale_price))
			{
			$discount = ($product->regular_price - $product->sale_price) * $product_data['quantity'];
			$discount_total+= $discount;
			}
		}
if ($discount_total > 0)
		{
		echo '
' . __('Bu Siparişten Kazancınız:', 'woocommerce') . ' ' . wc_price($discount_total + $woocommerce->cart->discount_cart) . '
'; } } add_action('woocommerce_cart_totals_after_order_total', 'bbloomer_wc_discount_total'); add_action('woocommerce_review_order_before_payment', 'bbloomer_wc_discount_total');

 

Exit mobile version