【问题标题】:WooCommerce custom coupon discountWooCommerce 自定义优惠券折扣
【发布时间】:2016-08-08 11:07:26
【问题描述】:

我正在尝试将默认 WooCommerce 优惠券折扣更改为将折扣价格添加到购物车总价格的功能。因此,与其减去折扣,不如将其加到价格中。

我发现这是在 includes/class-wc-cart.php 文件中的一个函数中完成的:
get_discounted_price 和 woocommerce_get_discounted_price

我尝试添加一个过滤器来完成上述操作,但效果不佳:

function custom_discount($price) {
     global $woocommerce;
     $undiscounted_price = $price;
     $product = $values['data'];
     $discount_amount = $coupon->get_discount_amount( 'yes' === get_option( 'woocommerce_calc_discounts_sequentially', 'no' ) ? $price : $undiscounted_price, $values, true );
     $discount_amount = min( $price, $discount_amount );
$price  = max( $price + $discount_amount, 0 );
  return $price;
}
add_filter( 'woocommerce_get_discounted_price', 'custom_discount', 10);

谁能帮我解决这个问题?

谢谢

【问题讨论】:

  • 您是否搜索过有关增加费用而不是为此使用优惠券的信息?请告诉我,谢谢。

标签: php wordpress woocommerce coupon price


【解决方案1】:

好的,一个可行的方法是设置负优惠券折扣,例如 -10:)

【讨论】:

    猜你喜欢
    • 2015-09-08
    • 2012-12-27
    • 2015-11-13
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    • 2021-12-31
    • 2020-11-04
    • 2014-07-26
    相关资源
    最近更新 更多