WooCommerce 第2页

Woocommerce实现按消费总额回馈用户

Woocommerce是一个完善的商城系统,我们能在此基础上实现一些功能,今天想到的是根据用户消费总额,给用户发放一个优惠券之类的,或者给用户一个标记,用来营销。 下面的代码是对用户进行处理,...
KEKC的头像-KEKC博客KEKC2年前
013210

将反转WooCommerce产品评论的显示顺序

function sd_newest_reviews_first( $args ) { $args['reverse_top_level'] = true; return $args; } add_filter( 'woocommerce_product_review_list_args', 'sd_newest_reviews_first' );
KEKC的头像-KEKC博客KEKC2年前
13113
woocommerce收货地址、配送地址显示模板设置-KEKC博客

woocommerce收货地址、配送地址显示模板设置

代码如下: add_filter( 'woocommerce_localisation_address_formats', 'woocommerce_custom_address_format', 20 ); function woocommerce_custom_address_format( $formats ) { $formats[ 'JP...
KEKC的头像-KEKC博客KEKC2年前
01312

woocommerce货币操作

相关源码文件地址: /wp-content/plugins/woocommerce/includes/wc-core-functions.php 1、更改货币符号 在woocommerce中,有的货币符号会导致辨识度问题,比如人民币和日元、加元和美元,单单...
KEKC的头像-KEKC博客KEKC2年前
012810

分批替换文章内容

以产品内容为例: $newcontent = str_replace('<strong>Measurements</strong>','<strong>Body Measurements</strong>',$yuan); $args = array( 'numberposts' => -1, 'post_type' ...
KEKC的头像-KEKC博客KEKC2年前
12411

判断优惠券(coupon)是否能用于当前产品

需要根据业务自己改,下方代码的意思是《如果当前产品能使用优惠券,则在产品简短描述中添加内容,我代码添加的是短代码》: //在符合优惠券的产品中输出内容 function apply_coupon_code_block...
KEKC的头像-KEKC博客KEKC1年前
012312

批量设置文章描述

以批量修改产品excerpt为例: $all_products = get_posts( array( 'post_type' => 'product', 'product_cat' => 'torso-doll', 'numberposts' => -1, 'post_status' => 'publish', 'post_excerp...
KEKC的头像-KEKC博客KEKC2年前
1238
WooCommerce显示计划优惠倒计时-KEKC博客

WooCommerce显示计划优惠倒计时

在WooCommerce中,可以设置计划优惠,从开始到结束日期享受一定优惠,但是默认的却不显示优惠时间倒计时,于是我决定研究一下。写出了下面的代码: add_filter('woocommerce_get_price_html',fu...
KEKC的头像-KEKC博客KEKC1年前
01224

woocommerce不同支付方式显示不同的购买按钮

代码: // 分期购买支付方式(cheque)按钮文字变更 add_action('woocommerce_review_order_before_submit','change_cheque_button_text'); function change_cheque_button_text(){ ?> <scri...
KEKC的头像-KEKC博客KEKC2年前
11912

woocommerce订单满减(订单达到多少应用优惠券)

下方代码,当订单金额到达50时,应用一张优惠券: /** * Apply a coupon for minimum cart total */ add_action( 'woocommerce_before_cart' , 'add_coupon_notice' ); add_action( 'woocommerc...
KEKC的头像-KEKC博客KEKC2年前
11815

WooCommerce中的优惠券验证例子

我们有一个需求:coupon1和coupon2是两个优惠券,coupon1和coupon2都能单独使用,并且coupon1只能与coupon2一起使用,同理coupon2也只能与coupon1一起使用。 代码如下: // coupon1与 coupon2优...
KEKC的头像-KEKC博客KEKC10个月前
01174

WooCommerce中使用代码创建优惠券

前面一篇文章,我使用代码创建了优惠券,如果放到一起会变得杂乱、不全面,所以单独拉出一个文章,讲讲如何使用代码创建优惠券。 我们回到优惠券的本质,其实优惠券也是文章类型,储存在wp_post...
KEKC的头像-KEKC博客KEKC1年前
011715

woocommerce结账页国家排序

结账页国家排序 //结账页国家排序 add_filter( 'woocommerce_countries_allowed_countries', 'sdf_countries_order', 99999, 1 ); function sdf_countries_order( $countries ) { $new_countrie...
KEKC的头像-KEKC博客KEKC2年前
1139
WooCommerce根据Tag实现增加运费-KEKC博客

WooCommerce根据Tag实现增加运费

有时候我们的运费可能并不是根据地区来设置多少运费,可能根据的是产品本身的属性统一进行设置费用,往往某一类产品单独增加费用,只借助地区的话无法达到这样的效果。 所以我就想到根据Tag设置...
KEKC的头像-KEKC博客KEKC1年前
01117

使用Golang检查woocommence产品图库是否超过大小

可以批量跑出存在大于某个大小产品图库的所有产品ID,也可以调整下输出,处理图片或者再写个压缩的函数进行压缩。实际测试跑5000多个产品,21秒钟跑完了,速度很快。 代码: package main impor...
KEKC的头像-KEKC博客KEKC2年前
01096

Woodmart主题中的html block兼容Stackable插件

这篇文章是让Woodmart主题中的html block兼容Stackable插件,Woodmart主题中的html block默认是不支持古腾堡的,更别提古腾堡插件Stackable。 将下面的代码放到主题functions.php里 让html bloc...
KEKC的头像-KEKC博客KEKC6个月前
010911
WooCommerce的order编辑页添加meta box的注意事项-KEKC博客

WooCommerce的order编辑页添加meta box的注意事项

在WooCommerce中,后台order编辑页面可以手动添加自定义字段,而无需meta box。 但是,我们有时候就需要在编辑页开发我们的功能,避免不了使用meta box,也就需要自定义字段来辅助。这其中就有...
KEKC的头像-KEKC博客KEKC7个月前
01044

woocommerce订单结账后执行操作

订单结账后发送邮箱: /** * Send an email each time an order with coupon(s) is completed * The email contains coupon(s) used during checkout process * */ function woo_email_order_co...
KEKC的头像-KEKC博客KEKC2年前
1039

woocommerce在产品卡片下增加内容

我这里以添加发布日期为例: 方法有很多,我是直接修改的价格显示 add_filter('woocommerce_get_price_html',function($html){//添加时间显示 if (in_the_loop()) { $html = $html.'<br>'.th...
KEKC的头像-KEKC博客KEKC2年前
0974

WooCommerce新建一个运输方式

代码来源官网: <?php /* Plugin Name: Your Shipping plugin Plugin URI: https://woocommerce.com/ Description: Your shipping method plugin Version: 1.0.0 Author: WooThemes Author U...
KEKC的头像-KEKC博客KEKC2年前
939

PHP中的价格精度处理

价格的精度处理在程序中至关重要,在WooCommerce中就有一连串的函数对价格进行精度操作。我提取出来是这样的,可以在任何程序中使用: <?php // 消毒 function sanitize_text( $str, $keep_n...
KEKC的头像-KEKC博客KEKC12个月前
09213