WooCommerce共46篇 第2页

分批替换文章内容

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

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

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

在WooCommerce中,订单状态改变的钩子

在WooCommerce中,有一个订单状态改变的钩子,这个钩子叫做:woocommerce_order_status_changed。 这个钩子有很大的用途,像网上那些积分插件、分销插件,底层就是这个钩子处理订单的。或者你还...
KEKC的头像-KEKC博客KEKC1个月前
010710
woocommerce收货地址、配送地址显示模板设置-KEKC博客

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

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

WooCommerce中使用代码创建优惠券

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

WooCommerce中优惠券验证的分析

在WooCommerce中,优惠券功能其实是很强大的,在创建时,我们能看到许多限制,在很多情况下,我们不能让用户使用优惠券,这就需要对优惠券的验证非常了解。 在woocommerce/includes/class-wc-di...
KEKC的头像-KEKC博客KEKC1个月前
0993

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

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

woocommerce结账页国家排序

结账页国家排序 //结账页国家排序 add_filter( 'woocommerce_countries_allowed_countries', 'sdf_countries_order', 99999, 1 ); function sdf_countries_order( $countries ) { $new_countrie...
KEKC的头像-KEKC博客KEKC10个月前
979

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

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

为WooCommerce的支付添加回调

之前也有写过类似插件,但是没记录,今天我重新记录一下,防止忘记。 代码如下: // 添加回调地址 add_action('woocommerce_api_wc_my_callback', 'my_callback_function'); // 回调函数 functi...
KEKC的头像-KEKC博客KEKC1个月前
09610
WooCommerce显示计划优惠倒计时-KEKC博客

WooCommerce显示计划优惠倒计时

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

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博客KEKC12个月前
899
WooCommerce根据Tag实现增加运费-KEKC博客

WooCommerce根据Tag实现增加运费

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

woocommerce在产品卡片下增加内容

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

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博客KEKC12个月前
769

复制WooCommerce订单发货地址到剪贴板上

<?php /* Plugin Name: Copy WooCommerce order shipping address to clipboard Plugin URI: https://www.damiencarbery.com/2022/11/copy-woocommerce-order-shipping-address-to-clipboard...
KEKC的头像-KEKC博客KEKC12个月前
755

注册新的WooCommerce订单状态

// Register new status function register_in_progress_order_status() { register_post_status( 'wc-in-progress', array( 'label' => 'In progress', 'public' => true, 'show_in_admin_stat...
KEKC的头像-KEKC博客KEKC9个月前
0722

PHP中的价格精度处理

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

woocommerce添加buy now按钮

也有插件,自己研究了下,几行代码搞定。 1、先在产品单页form表单里添加一个按钮,用于点击,同时按钮里添加一个产品ID的属性提交用于处理: //添加立即购买按钮 add_action('woocommerce_afte...
KEKC的头像-KEKC博客KEKC7个月前
06615
批量追加Woocommerce产品的属性值-KEKC博客

批量追加Woocommerce产品的属性值

公司在前期并未增加任何产品的属性值,用了标签,但是现在想增加属性值这样就能使用属性在侧边筛选出产品。于是我写了一套程序,可以自动追加产品属性,目前是按照分类的slug进行操作的,你也可...
KEKC的头像-KEKC博客KEKC5个月前
0645

WooCommerce实现商品浏览历史纪录

原理是访问产品时往浏览器中写入Cookies,再通过Cookies存储的产品ID写成短代码展现,最后通过调用短代码实现显示产品。 代码如下,亲测可用: add_action( 'template_redirect', 'bbloomer_tra...
KEKC的头像-KEKC博客KEKC3个月前
0637