hook-woocommerce 相关问题

将此标记用于与WooCommerce挂钩相关的问题。 WooCommerce中的一个钩子允许插件或主题“挂钩”代码;也就是说,在特定时间调用此插件中的函数。

根据所选国家/地区设置 WooCommerce 结帐账单字段邮政编码默认值

我需要在帐单邮政编码字段中设置默认值,具体取决于所选的国家/地区,我使用了以下代码,但它无法正常工作: add_filter('woocommerce_checkout_fiel...

回答 1 投票 0

在结账账单字段中设置值

我需要在帐单邮政编码字段中设置默认值,具体取决于所选国家/地区,我使用了以下代码,但它无法正常工作: add_filter('woocommerce_checkout_fiel...

回答 1 投票 0

WooCommerce 没有可用的付款方式

我正在为 woocommerce 创建自定义支付网关。虽然它显示在管理员上,但在结账页面上不可用。请参阅下面我的代码 我正在为 woocommerce 创建自定义支付网关。虽然它显示在管理员上,但在结帐页面上不可用。请参阅下面的代码 <?php /* Plugin Name: Custom Payment Gateway Description: Custom payment gateway for WooCommerce. Version: 1.0 Author: Your Name */ if (!defined('ABSPATH')) { exit; // Exit if accessed directly. } // Initialize the gateway add_action('plugins_loaded', 'init_custom_gateway'); function init_custom_gateway() { if (!class_exists('WC_Payment_Gateway')) { return; } class WC_Custom_Gateway extends WC_Payment_Gateway { public function __construct() { $this->id = 'custom_gateway'; $this->method_title = __('Custom Gateway', 'woocommerce'); $this->method_description = __('Custom payment gateway for WooCommerce', 'woocommerce'); $this->title = $this->get_option('title'); $this->has_fields = true; // Load settings $this->init_form_fields(); $this->init_settings(); // Define user set variables $this->title = $this->get_option('title'); // Actions add_action('woocommerce_update_options_payment_gateways_' . $this->id, array($this, 'process_admin_options')); add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page')); } // Gateway Fields public function init_form_fields() { $this->form_fields = array( 'enabled' => array( 'title' => __('Enable/Disable', 'woocommerce'), 'type' => 'checkbox', 'label' => __('Enable Custom Gateway', 'woocommerce'), 'default' => 'yes', ), 'title' => array( 'title' => __('Title', 'woocommerce'), 'type' => 'text', 'description' => __('Payment method title that the customer will see on your website.', 'woocommerce'), 'default' => __('Custom Gateway', 'woocommerce'), 'desc_tip' => true, ), ); } // Payment form on checkout page public function payment_fields() { echo '<p>' . __('Custom payment information', 'woocommerce') . '</p>'; } // Process the payment and return the result public function process_payment($order_id) { $order = wc_get_order($order_id); // Mark as on-hold (we're awaiting the cheque) $order->update_status('on-hold', __( 'Awaiting cheque payment', 'woocommerce' )); // Mark as processing (payment received) // $order->update_status('processing'); // Reduce stock levels // $order->reduce_order_stock(); wc_reduce_stock_levels( $order_id ); // Remove cart WC()->cart->empty_cart(); // Return a success redirect return array( 'result' => 'success', 'redirect' => $this->get_return_url($order), ); } // Receipt page public function receipt_page($order_id) { echo '<p>' . __('Thank you for your order.', 'woocommerce') . '</p>'; } } // Register the gateway function add_custom_gateway($methods) { $methods[] = 'WC_Custom_Gateway'; return $methods; } add_filter('woocommerce_payment_gateways', 'add_custom_gateway'); } 我已在 Woocommerce 设置下激活并启用了该插件,但仍然无法工作 我的结帐页面看起来仍然像那样 我可能做错了什么? 你找到解决办法了吗?我也有同样的问题。

回答 1 投票 0

根据 WooCommerce 中的客户帐单国家/地区更改产品价格

我需要根据帐单国家/地区更改货币,使用以下代码可以以某种方式进行操作,但它仅适用于简单的产品,不适用于可变产品。 添加过滤器('

回答 1 投票 0

根据帐单所在国家/地区更改货币

我需要根据帐单国家/地区更改货币,使用以下代码可以以某种方式实现,但它仅适用于简单的产品,不适用于可变的产品。 添加过滤器('

回答 1 投票 0

在 WooCommerce 订单快速视图中显示订单总额

我想在订单预览弹出窗口中显示订单总数,如下图所示。

回答 1 投票 0

在 Woocommerce 管理订单预览中显示订单总额

我想在订单预览弹出窗口中显示订单总数,如下图所示。

回答 1 投票 0

在 WooCommerce 中单击时自动更新购物车

我想在数量更改时自动更新购物车。我在functions.php 中得到了这个工作代码,但它仅适用于第一次单击。如何调整它以便每次点击都有效? 添加_...

回答 10 投票 0

如何根据自定义结帐字段设置要应用于订单的 WooCommerce 税级?

在 WooCommerce 中,我需要在我的结账页面添加一个“billing_legal_person”自定义字段,可以在“Person”和“Company”之间进行选择,以反映客户是否

回答 1 投票 0

检查从 WooCommerce 版本 8.2.2 到 8.3.1 的更改

最近我们的插件在 WooCommerce 版本 8.3.1 上遇到一些问题,但现在可以正常工作。我们已将 WooCommerce 版本降低到 8.2.2 并解决了旧错误,但现在出现了新问题

回答 1 投票 0

WooCommerce WC()->cart->remove_cart_item 可以工作,但需要刷新页面才能看到该项目已被删除

当我点击结账页面上的“下订单”按钮时,我想重新检查我的购物车中是否有任何不应包含在订单中的产品。如果有匹配的产品...

回答 1 投票 0

在 WooCommerce 的存档页面问题上在价格前添加文本

如果产品在 WooCommerce 的存档页面上出售,我将使用以下代码在价格前添加文本: 函数 wps_custom_message() { $产品 = wc_get_product(); 如果($

回答 2 投票 0

在 Woocommerce 类别页面问题的价格之前添加文本

如果产品在 woocommerce 的类别页面上打折,我将使用此挂钩在价格前添加文本,但该文本也会出现在未设置销售价格的产品上。可以请你...

回答 1 投票 0

Elementor 标题不会出现在 WooCommerce 页面中

我使用插件 Elementor 页眉和页脚生成器创建了一个页眉。 标头完美应用于所有页面,但与 WooCommerce 相关的所有页面都具有旧标头。 我不知道...

回答 1 投票 0

WooCommerce 在变体标签后显示内容

我想在变体名称后添加内容。 我找到这个钩子并看到它之前可以工作,但在我的测试中它不是:( 我想问,是否有另一种钩子/工作方法可以用来添加内容?

回答 2 投票 0

如何避免 PHP 注意:在 wp_loaded 操作之前不应调用 Get cart

我想在 woocommerce 结帐页面中仅对“lms”类别中的产品进行电话 OTP 验证,然后创建以下片段: 函数hkioh_is_lms_product_in_cart() {

回答 1 投票 0

我收到一条 PHP 通知:get_cart 被错误调用。在 wp_loaded 操作之前不应调用获取购物车

我想在 woocommerce 结帐页面中仅对“lms”类别中的产品进行电话 OTP 验证,然后创建以下片段: 函数hkioh_is_lms_product_in_cart() {

回答 1 投票 0

如何通过分类自动为每个变体分配属性? Woocommerce

我创建了代码,允许您保存 CSV 文件,在 WooCommerce 产品编辑器页面上创建产品变体,然后发布产品属性和分类法,但是...

回答 1 投票 0

将 WooCommerce 捆绑产品添加到简短说明上方的购物车部分

我正在使用名为 WooCommerce 产品捆绑包的插件,并且希望将捆绑产品移动到摘录(简短描述)上方的单个添加到卡片模板。 我猜它是通过这段代码实现的:

回答 1 投票 0

将“WooCommerce 捆绑产品”移至简短描述上方

我正在使用名为“Woocommerce 产品捆绑包”的插件,想要将捆绑产品移动并将“添加到卡片”按钮从摘要下方移动到摘录/简短描述上方。 我猜是

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.