我想向我的支付网关添加自定义图标。我已阅读 WOO 网关 API,但获得的帮助为零。这是我下面的代码。请帮助我找到一种包含该图标的实用方法,以便我的前端有一个图标。谢谢
\n\n<?php if ( ! defined( 'ABSPATH' ) ) { exit; }\n\nadd_filter( 'woocommerce_payment_gateways', 'init_wpuw_gateway' );\nfunction init_wpuw_gateway ( $methods ) \n{\n $methods[] = 'WC_Gateway_WPUW'; \n return $methods;\n}\n\n\nif( class_exists('WC_Payment_Gateway') ):\nclass WC_Gateway_WPUW extends WC_Payment_Gateway {\n\n /**\n * Constructor for the gateway.\n */\n public function __construct() {\n\n $plugin_dir = plugin_dir_url(__FILE__);\n\n $this->id = 'wpuw';\n\n //If you want to show an image next to the gateway\xe2\x80\x99s name on the frontend, enter a URL to an image.\n $this->icon = apply_filters( 'woocommerce_gateway_icon', ''.$plugin_dir.'/assets/paysecure.png' );\n …Run Code Online (Sandbox Code Playgroud) 插件名称:WooCommerce
插件\woocommerce\templates\global\form-login.php
<label for="username"><?php _e( 'Email', 'woocommerce' ); ?> <span class="required">*</span></label>
Run Code Online (Sandbox Code Playgroud)
它显示电子邮件而不是我想要的用户名或电子邮件
包括\class-wc-form-handler.php
if ( empty( $username ) ) {
throw new Exception( '<strong>' . __( 'Error:', 'woocommerce' ) . '</strong> ' . __( 'Email is required.', 'woocommerce' ) );
}
Run Code Online (Sandbox Code Playgroud)
它显示电子邮件验证正确,但也使用用户名登录
我希望它在结帐前仅使用电子邮件和密码登录
我正在尝试获取含税的常规产品价格,但我找不到任何用于此目的的 WooCommerce 函数或变量。
为了获得常规产品的不含税价格,我使用:
$price = $product->get_regular_price();
Run Code Online (Sandbox Code Playgroud)
但如何才能得到正常产品的含税价格呢?
按照这篇文章的思路,当管理员使用我的支付网关通过管理面板创建订单时,我尝试连接到我自己的自定义支付网关。
我添加了以下代码:
add_action( 'woocommerce_process_shop_order_meta', array( $this, 'process_offline_order' ) );
add_action( 'woocommerce_admin_order_actions_end', array( $this, 'process_offline_order2' ) );
add_action( 'woocommerce_save_post_shop_order', array( $this, 'process_offline_order3' ) );
Run Code Online (Sandbox Code Playgroud)
我尝试将 xdebug 断点放入这些相应的方法中,但没有一个被击中。
在我的网站上(使用 Woocommerce 3.2.6),我想仅为登录用户隐藏“添加到购物车”按钮。
我有这个代码:
add_action('init', 'hide_price_add_cart_logged_in');
function hide_price_add_cart_logged_in() {
if ( is_user_logged_in() ) {
remove_action( 'woocommerce_after_shop_loop_item',
'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 30 );
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:有人建议我使用这个:
add_action('init', 'hide_price_add_cart_logged_in');
function hide_price_add_cart_logged_in() {
if ( is_user_logged_in() ) {
remove_action( 'woocommerce_after_shop_loop_item',
'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_single_product_summary',
'woocommerce_template_single_add_to_cart', 30 );
return WooCommerce::instance();
}
}
Run Code Online (Sandbox Code Playgroud)
但这没有用...
我已将此代码插入到我的主题的functions.php 文件中,但它似乎没有进行任何更改。在检查某些产品时,我仍然看到“添加到购物车”按钮。
怎么去掉那个按钮呢?我的函数哪里出错了?
我想在通过“我的帐户”页面更新地址时在计费电话上添加验证。
表格位置: http: //www.example.com/my-account/edit-address/billing
我的代码到目前为止如下:-
add_action( "woocommerce_customer_save_address", 'custom_validation');
function custom_validation($user_id,$load_address)
{
if ( $user_id <= 0 )
{
return;
}
if(isset($_POST['billing_phone']))
{
$account_billing_phone = ! empty( $_POST['billing_phone'] ) ? wc_clean( $_POST['billing_phone'] ) : '';
$get_user = wp_get_current_user();
$user_phone = get_user_meta( $get_user->ID, 'billing_phone', true );
if(strlen($account_billing_phone) !== 10 )
{
wc_add_notice( __( 'Enter a valid 10 digit mobile number', 'woocommerce' ), 'error' );
}
elseif($account_billing_phone !== $user_phone)
{
$user_exist = get_users(array('meta_value' => array($account_billing_phone)));
if($user_exist)
{
wc_add_notice( __( 'Mobile number already exist.', …Run Code Online (Sandbox Code Playgroud) 我需要防止每天通过 woocommerce 中的 IP 地址销售超过 30 件商品。基本上,它是针对机器人的保护。我认为逻辑必须是这样的:
*用户注册已禁用
所以我不确定从哪里开始以及如何遵循 woocommerce hooks 规则。
任何代码示例将不胜感激
在WooCommerce我想隐藏股票出从产品的相关产品在单品页。是否可以?
任何曲目表示赞赏。
在 Woocommerce 中,我想更改应始终用作所有电子邮件通知的回复地址的电子邮件地址。
Woocommerce 怎么可能做到这一点?
php wordpress email-notifications woocommerce hook-woocommerce