php Mu-plugin允许您在Marketpress中为指定的送货方式免费送货,如果购物车总数大于设定的最低限额,免费送货
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php Mu-plugin允许您在Marketpress中为指定的送货方式免费送货,如果购物车总数大于设定的最低限额,免费送货相关的知识,希望对你有一定的参考价值。
<?php
$free_ship_minimum = 100; // minimum total for free shipping to be applied
$shipping_method = 'weight_rate'; // the shipping method for this to be applied on.
/*
* Changes the Shipping cost on the Checkout Estimated costs page
*/
add_filter( 'mp_cart/cart_meta/shipping_total', 'mp_custom_shipping_price', 88, 2);
/*
* Changes the estimated shipping total text to Free if cart total is above $free_ship_minimum
*/
function mp_custom_shipping_price( $shipping_line, $this ) {
global $mp_cart, $free_ship_minimum, $shipping_method;
$cart_total = $mp_cart->total(false) - $mp_cart->shipping_total(false);
if ($shipping_method == mp_get_setting( 'shipping->method' ) && $cart_total >= $free_ship_minimum) {
$shipping_line = '
<div class="mp_cart_resume_item mp_cart_resume_item-shipping-total">
<span class="mp_cart_resume_item_label">' . __( 'Shipping', 'mp' ) . '</span>
<span class="mp_cart_resume_item_amount">Free</span>
</div><!-- end mp_cart_resume_item-shipping-total -->';
}
return $shipping_line;
}
add_filter( 'mp_cart/total', 'mp_custom_shipping_price_total', 99, 3);
/*
* Deducts shipping total from cart Estimaed total if cart total above $free_ship_minimum
*/
function mp_custom_shipping_price_total( $total, $item_total, $this ) {
global $mp_cart, $free_ship_minimum, $shipping_method;
$cart_total = $total - $mp_cart->shipping_total(false);
if ($shipping_method == mp_get_setting( 'shipping->method' ) && $cart_total >= $free_ship_minimum) {
$custom_total = $total - $mp_cart->shipping_total(false);
}
return $custom_total;
}
/*
* Sets the shipping cost to 0 if cart total greater than $free_ship_minimum
*/
add_filter( 'mp_calculate_shipping_weight_rate', 'mp_custom_shipping_total', 100, 10 );
function mp_custom_shipping_total($custom_total, $total, $cart, $address1, $address2, $city, $state, $zip, $country, $selected_option) {
global $mp_cart, $free_ship_minimum, $shipping_method;
$cart_total = $total - $mp_cart->shipping_total(false);
if ($shipping_method == mp_get_setting( 'shipping->method' ) && $cart_total >= $free_ship_minimum) {
return 0;
}
}
以上是关于php Mu-plugin允许您在Marketpress中为指定的送货方式免费送货,如果购物车总数大于设定的最低限额,免费送货的主要内容,如果未能解决你的问题,请参考以下文章
php mu-plugin carga condicional插件
php WordPress mu-plugin概念证明可自动禁用开始抛出错误的插件。
php WordPress mu-plugin概念证明可自动禁用开始抛出错误的插件。
php 在the_content()之前或之后添加HTML或Shortcode - WordPress mu-plugin
php WordPress mu-plugin,添加管理栏集成,以指示dev / staging网站是干净还是脏。 https://cloudup.com/cip1BZXH8kC
php WordPress mu-plugin,添加管理栏集成,以指示dev / staging网站是干净还是脏。 https://cloudup.com/cip1BZXH8kC