Tag: 结帐

在woocommerce中有条件地设置结帐领域

如何从服务器端有条件地取消设置其他两个字段并从中删除所需的validation? 以下是表单的外观: 这是代码: function bs_filter_checkout_fields($fields){ $fields[‘billing’] = array( ‘add_type’ => array( ‘type’ => ‘radio’, ‘label’ => __( ‘Address Type’ ), ‘options’ => array( ‘house’ => __( ‘House’ ), ‘building’ => __( ‘Building’ ), ‘office’ => __( ‘Office’ ) ), ‘required’ => true ), ‘add_house_name’ => array( ‘type’ => ‘text’, ‘required’ => true, ‘placeholder’ => __( […]

在Woocommerce中显示或隐藏所选送货方式更改的html元素

我正在尝试根据所选的送货方式显示/隐藏我的结帐页面中的一些元素。 我试图显示/隐藏的页面元素来自另一个插件,因此我尝试更改它们的显示属性。 我看过很multithreading: 根据Woocommerce 3中的送货方式显示或隐藏结帐字段 但它适用于结帐字段,我不知道如何为页面元素执行此操作。 然后基于这个答案线程这是我的代码到目前为止: add_action( ‘wp_footer’, ‘conditionally_hidding_order_delivery_date’ ); function conditionally_hidding_order_delivery_date(){ // Only on checkout page if( ! is_checkout() ) return; // HERE your shipping methods rate ID “Home delivery” $home_delivery = ‘distance_rate_shipping’; ?> jQuery(function($){ // Choosen shipping method selectors slug var shipMethod = ‘input[name^=”shipping_method”]’, shipMethodChecked = shipMethod+’:checked’; // Function that shows or […]

根据选择器选择显示自定义结帐字段

基于这个工作答案: 自定义下拉选择器显示或隐藏其他Checkout自定义字段 在WooCommerce结帐页面中,我使用下面的代码创建一些其他自定义字段并重新排序所有结帐字段。 我使用jQuery脚本根据选择器选项显示/隐藏一些字段。 这是我的新代码: // Registering external jQuery/JS file function cfields_scripts() { /* IMPORTANT NOTE: For a child theme replace get_template_directory_uri() by get_stylesheet_directory_uri() The external cfields.js file goes in a subfolder “js” of your active child theme or theme.*/ wp_enqueue_script( ‘checkout_script’, get_template_directory_uri().’/js/cfields.js’, array(‘jquery’), ‘1.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘cfields_scripts’ ); add_filter( ‘woocommerce_checkout_fields’, ‘custom_checkout_billing_fields’ […]

结帐字段:隐藏和显示现有字段

基于这个工作答案: // Registering external jQuery/JS file function cfields_scripts() { // IMPORTANT NOTE: // For a child theme replace get_template_directory_uri() by get_stylesheet_directory_uri() // The external cfields.js file goes in a subfolder “js” of your active child theme or theme. wp_enqueue_script( ‘checkout_script’, get_template_directory_uri().’/js/cfields.js’, array(‘jquery’), ‘1.0’, true ); } add_action( ‘wp_enqueue_scripts’, ‘cfields_scripts’ ); add_filter( ‘woocommerce_checkout_fields’, ‘ba_custom_checkout_billing_fields’ ); function […]

如何防止Woocommerce在Checkout页面上选择默认付款方式?

在结帐页面上显示付款方式,默认情况下会自动选择第一个付款方式。 我需要阻止选择,因此WC最初没有选择付款方式。 到目前为止我尝试了两件事: 来自Chrome控制台的jQuery: jQuery(’。payment_methods input.input-radio’)。prop(’checked’,false); 结果: [​, ​] 从payment-method.php Woocommerce模板文件中删除代码: 选中($ gateway-> selected,false); 两者都不起作用。 怎么做? 请问有什么片段或建议吗? 编辑: 还试过这个: function wpchris_filter_gateways( $gateways ){ global $woocommerce; foreach ($gateways as $gateway) { $gateway->chosen = 0; } return $gateways; } add_filter( ‘woocommerce_available_payment_gateways’, ‘wpchris_filter_gateways’, 1);

WooCommerce条件自定义结帐字段

在WooCommerce中,我目前正在尝试在Checkout中添加一个条件自定义字段,该字段显示一个复选框,如果选中该复选框,则会显示一个输入字段以插入意大利语财务代码(Codice Fiscale)。 感谢各种指南和插件代码,我能够在结帐时显示它,但我做错了代码并有几个问题: 默认情况下,我希望它是非必需字段,只有在检查它必须是必需的。 如果我尝试继续购物车插入有效或非抄本fiscale我得到此错误“语法错误:在位置0的JSON中的意外令牌<”我的主题通常显示结帐错误。 仅以意大利语显示所有这些(使用WPML) 我无法解决进一步的错误,而我无法解决前两点。 注意:意大利法律要求如果私人客户要求发票,他必须同时插入他的(有效) “codice fiscale” (财政代码) 。 为了避免复杂化,我没有插入任何高级检查工具(这将需要更多的字段,如生日)。 相反,我通过模式标记设置了这个简短的控件: jQuery(‘#cf_in’).prop(‘pattern’, “^[a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9]{3}[a-zA-Z]$”); 我在互联网上找到它,但不知道它是否可行。 我也有这个: function isCodiceFiscaleValid($valore,$codice_fiscale = true){ $espressione = “^[az]{6}[0-9]{2}[az][0-9]{2}[az][0-9]{3}[az]$”; if(!$codice_fiscale){ $espressione = “^[0-9]{11}$”; } if ( eregi($espressione, $valore) ) { return true; } return false; } 检查后,一旦插入“Codice fiscale” (财政代码)好,我们就可以继续结账,为客户显示并管理这个“codice fiscale”。 我还需要使用WooCommerce PDF Invoices&Packing Slips Pro插件(商业版)在PDF发票上打印。 这里的参考文献(不幸的是只能发布2): Link1(自定义插件) , Link2(JS检查,注意在同一个网站上也有php检查) […]

自定义下拉选择器显示或隐藏其他Checkout自定义字段

我使用此代码创建自定义结帐字段并重新排序字段: add_filter( ‘woocommerce_checkout_fields’, ‘custom_checkout_billing_fields’ ); function custom_checkout_billing_fields( $fields ) { // 1. Creating the additional custom billing fields // The “status” selector $fields[‘billing’][‘billing_status’][‘type’] = ‘select’; $fields[‘billing’][‘billing_status’][‘class’] = array(‘form-row-wide, status-select’); $fields[‘billing’][‘billing_status’][‘required’] = true; $fields[‘billing’][‘billing_status’][‘label’] = __(‘User status’, ‘my_theme_slug’); $fields[‘billing’][‘billing_status’][‘placeholder’] = __(‘Chose an option’, ‘my_theme_slug’); $fields[‘billing’][‘billing_status’][‘options’] = array( ” => ‘Chose an option’, ‘1’ => ‘Legal entity’, […]