我的购物车中有 3 种运输方式,一旦您的客户输入免费送货优惠券,这些方式的价格就应该为零。
我知道如何在functions.php中添加过滤器来检测优惠券,但有人知道将购物车(单选按钮)中可见的运输方法设置为零的代码片段吗?
我的送货方式是 UPS、FedEx 等公司...
我激活了免费送货选项,以便可以使用优惠券进行管理。
客户选择的送货方式列表是根据我的产品运输等级和订单总重量计算的。
运输类别不是计算的,而是由产品设置的,我使用表费率插件来计算重量。
我正在 woocommerce 网站上工作,我试图限制仅在应用优惠券时才购买产品,因此在不添加优惠券代码的情况下不应对其进行处理。用户必须输入优惠券代码才能订购该特定产品(不适用于所有其他产品)。
任何帮助表示赞赏。
我使用正常的 woocommerce 优惠券方法创建了一张“ BOGOF ”(买一送一)优惠券。
该优惠券为用户提供购物车中其他 1 件商品 100% 的折扣。
优惠券设置
一般的:
折扣类型:百分比折扣 优惠券
数量:100
使用限制:
- 限制使用 X 项:1
使用时:
期望:
通过以下代码,我尝试实现我的目标,不幸的是没有达到预期的结果
function filter_woocommerce_coupon_get_discount_amount( $discount, $discounting_amount, $cart_item, $single, $instance ) {
$price_array = array();
foreach( $cart_item as $item ) {
echo $item->price;
if($item->price > 0){
array_push($price_array, $item->price);
}
}
$lowestPrice = min($price_array);
if( $lowestPrice < $discount ){
$discount = $lowestPrice;
}
return $discount;
}
add_filter( 'woocommerce_coupon_get_discount_amount', 'filter_woocommerce_coupon_get_discount_amount', 10, 5 …
Run Code Online (Sandbox Code Playgroud) 我想从所有 WooCommerce 优惠券中排除具有特定属性的产品(例如 attribute_pa_brand => mybrand)。
我遵循了这个答案,从 Woocommerce 中的优惠券使用中排除具有 2 个特定属性术语的变体 ,但它似乎仅适用于Variable Product类型,而我只需要它用于Simple Product。
我将不胜感激任何答复。
我有以下循环用于在客户仪表板的我的帐户部分的页面上获取 Woocommerce 优惠券。
目前我们有 10k+ 优惠券,仅仅通过执行这个循环,就会消耗大量资源,而且效率不高,导致超时。有什么明显的方法可以提高效率吗?
有没有办法可以将循环限制为仅搜索“允许的电子邮件”字段中的电子邮件(因为每个优惠券都与电子邮件地址绑定)?
<?php $smart_coupons = get_posts( array(
'posts_per_page' => -1,
'orderby' => 'name',
'order' => 'desc',
'post_type' => 'shop_coupon',
'post_status' => 'publish'
) );
if ( $smart_coupons ) {
foreach( $smart_coupons as $smart_coupon) {
$strcode = strtolower($smart_coupon->post_title);
$full_coupon = new WC_Coupon( $strcode ); ?>
<?php if($full_coupon->discount_type == "smart_coupon"){
$emails = $full_coupon->get_email_restrictions();
if (in_array($current_email, $emails)) {
if($full_coupon->usage_count < $full_coupon->usage_limit){ ?>
coupon content
<?php }
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 既然我们可以为订单中的每个产品应用不同的优惠券,那么有什么方法可以知道哪个优惠券应用于哪个产品呢?我使用过$order->get_used_coupons()
函数,但它只返回使用过的优惠券代码。
请帮忙解决。谢谢。
我正在尝试编写一个函数来检索使用指定优惠券代码且在指定日期范围内的WooCommerce订单列表,然后将应用于这些订单的总折扣加起来.
经过一番谷歌搜索,我觉得我应该使用类似的东西
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => ???,
'meta_value' => $CouponToSearchFor,
'post_type' => wc_get_order_types(),
'post_status' => array_keys( wc_get_order_statuses() ),
) );
Run Code Online (Sandbox Code Playgroud)
我试过了:
'meta_key' => 'coupon'
'meta_key' => 'shop_coupon'
'meta_key' => '_coupon'
Run Code Online (Sandbox Code Playgroud)
但这些都不起作用.我怎样才能找出哪些meta_key
/ meta_value
条款会给我我需要的东西?
另外我认为meta_query
可以用来执行日期过滤作为此get_posts()
查询的一部分,这是正确的吗?
我想限制优惠券代码"XYZ"仅用于定义的工作日,仅限周一至周四.其他日子(星期五到星期日)会显示错误通知.
可能吗?我怎样才能做到这一点?
谢谢
我有一个有 1000 张优惠券的网站。所有优惠券的使用限制为一张。我使用 Raunuk Gupta 提供的代码直接从 SQL 数据库导出优惠券。
是否可以检索使用优惠券的用户的订单元数据?我想在报告中包含用户的姓名、电子邮件地址和其他一些可能的自定义字段。
谢谢你。
示例 EXCEL 导出链接 -黄色字段来自优惠券 -蓝色字段来自订单
我有一个关于将 Woocommerce 优惠券字段插入任何页面所需的小项目,但这对我来说似乎很复杂。我在谷歌上搜索过这个,但没有任何关于这个的资源。找到这个关于插入字段的代码。
将此代码插入到文本块中:
<div class="redeem-coupon">
<form id="ajax-coupon-redeem">
<p>
<input type="text" name="coupon" id="coupon"/>
<input type="submit" name="redeem-coupon" value="Redeem Offer" />
</p>
<p class="result"></p>
</form><!-- #ajax-coupon-redeem -->
Run Code Online (Sandbox Code Playgroud)
这会生成表单,但没有其他代码可以将其处理到页面中?
是否可以通过短代码或其他方式生成?