WooCommerce共46篇 第2页

woocommerce添加buy now按钮

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

woocommerce在产品卡片下增加内容

我这里以添加发布日期为例: 方法有很多,我是直接修改的价格显示 add_filter('woocommerce_get_price_html',function($html){//添加时间显示 if (in_the_loop()) { $html = $html.'<br>'.th...
KEKC的头像-KEKC博客KEKC7个月前
0824
woocommerce通过钩子更改产品目录中的默认排序方式-KEKC博客

woocommerce通过钩子更改产品目录中的默认排序方式

woocommerce产品页中有几种排序方式,大多数主题中都支持更改默认排序方式,一改就所有都改了。但是保不齐哪个分类需要我们设置成另一种为默认排序。 以下是修改默认排序的方法,如以日期排序:...
KEKC的头像-KEKC博客KEKC9个月前
017912

注册新的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个月前
0712

分批替换文章内容

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

批量设置文章描述

以批量修改产品excerpt为例: $all_products = get_posts( array( 'post_type' => 'product', 'product_cat' => 'torso-doll', 'numberposts' => -1, 'post_status' => 'publish', 'post_excerp...
KEKC的头像-KEKC博客KEKC9个月前
1128

woocommerce修改使用的模板

add_filter('wc_get_template_part','change_checkout_order_received_template',10,3); function change_checkout_order_received_template($template, $slug, $name){ if($slug == 'checkout/...
KEKC的头像-KEKC博客KEKC10个月前
1215

woocommerce结账页国家排序

结账页国家排序 //结账页国家排序 add_filter( 'woocommerce_countries_allowed_countries', 'sdf_countries_order', 99999, 1 ); function sdf_countries_order( $countries ) { $new_countrie...
KEKC的头像-KEKC博客KEKC10个月前
979
Woocommerce在订单编辑时添加额外的action操作-KEKC博客

Woocommerce在订单编辑时添加额外的action操作

默认的订单action动作中有三个,如黄框中所示。 但是,我想添加一个其他操作,比如把订单同步到其他平台,或者是发送一个自定义的邮件内容,我们可以这么做,我这里以只发送订单信息为例子: 1...
KEKC的头像-KEKC博客KEKC10个月前
13412

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

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

WooCommerce管理员测试

代码: <?php /** * Plugin Name: Test Payment Module for Woocommerce * Plugin URI: http://www.tortoise-it.co.uk * Description: A payment gateway plugin for Woocommerce to handle ...
KEKC的头像-KEKC博客KEKC11个月前
12914
woocommerce自定义产品的选项卡-KEKC博客

woocommerce自定义产品的选项卡

在woocommerce的选项卡中,有一个过滤钩子,可以用这个钩子添加、修改、删除、排序我们的产品tabs选项卡。 添加(默认的代码): 可以看到,添加就是添加一个数组,在里面添加名称、排序、回调...
KEKC的头像-KEKC博客KEKC12个月前
1708

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订单满减(订单达到多少应用优惠券)

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

woocommerce订单总金额限制最低多少

下方代码限制最低5万: /** * Set a minimum order amount for checkout */ add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); add_action( 'woocommerce_before_cart...
KEKC的头像-KEKC博客KEKC12个月前
13915

复制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个月前
705

WooCommerce 输入数量更改时自动更新购物车

<?php add_action( 'wp_print_footer_scripts', function () { if ( ! function_exists( 'WC' ) ) return; if ( ! is_cart() ) return; ?> <script> jQuery && jQuery(($) => { l...
KEKC的头像-KEKC博客KEKC12个月前
11312

将反转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博客KEKC12个月前
11213

空购物车的提示

add_filter('wfacp_cart_empty_message',function(){ $shop_url = get_permalink( wc_get_page_id( 'shop' ) ); return __( 'Your cart is currently empty.<a href='.$shop_url.'>Click Her...
KEKC的头像-KEKC博客KEKC12个月前
5513

将《清除购物车按钮》添加到购物车页面和迷你购物车

代码: <?php // adds the button to the cart page add_action( 'woocommerce_cart_actions', 'woocommerce_empty_cart_button' ); function woocommerce_empty_cart_button() { echo '<...
KEKC的头像-KEKC博客KEKC12个月前
17911

WooCommerce根据用户是登录还是注销来显示/隐藏产品。

PHP代码如下: <?php add_action( 'woocommerce_product_query', 'show_hide_products_category_shop' ); function show_hide_products_category_shop( $q ) { $tax_query = (array) $q->get...
KEKC的头像-KEKC博客KEKC12个月前
16815