checkout

How to get product categories for the current order item?

空扰寡人 提交于 2021-01-28 05:29:56
问题 I am trying to get the product categories for the woocommerce order item at woocommerce_checkout_create_order_line_item hook. I am able to successfully get the product_id (thanks to help I got here) but now trying to get the product's categories the array comes back empty trying $product->get_categories() and alternatively trying wc_get_product_category_list($product->get_id(). I can't figure out what I am doing wrong. add_action('woocommerce_checkout_create_order_line_item', 'add_order_item

Reset previous chosen shipping method in Woocommerce checkout page

喜你入骨 提交于 2021-01-28 05:15:37
问题 Currently, I am clearing the default shipping selection method using this filter: add_filter( 'woocommerce_shipping_chosen_method', '__return_false', 99); However, this only clears it during the initial session of the customer. Once the customer chooses an option even once, it remembers the selection for the future. I am trying to get the checkout to force the customer to pick a shipping option every time they visit the checkout even in the same session. Is it possible to run this filter

Need shipping cost to depends on custom field (Woocommerce)

时间秒杀一切 提交于 2021-01-28 03:48:48
问题 I used Woocommerce Easy Checkout Fields Editor plugin to create a custom drop-down field in billing section. How do I make the cost of delivery vary depending on what is selected in this field (there are two options) 来源: https://stackoverflow.com/questions/46232628/need-shipping-cost-to-depends-on-custom-field-woocommerce

Change WooCommerce checkout country field default option displayed label

醉酒当歌 提交于 2021-01-28 02:58:16
问题 How would edit the default value on and existing array - have managed to edit the label using this but cannot get the options property to work using this: add_filter( 'woocommerce_checkout_fields', 'custom_override_checkout_fields' ); function custom_override_checkout_fields( $fields ) { $fields['billing']['billing_country']['options value="default"'] = 'My new select prompt'; $fields['billing']['billing_country']['label'] = 'Are you purchasing as a Company Y/N or from the UK?'; return

Remove some hooked functions based on virtual products in WooCommerce Checkout

允我心安 提交于 2021-01-28 02:00:56
问题 I want to remove some information on checkout page when there is only virtual products in cart. The following is removing what I want on checkout page: remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_checkout_privacy_policy_text', 20 ); remove_action( 'woocommerce_checkout_terms_and_conditions', 'wc_terms_and_conditions_page_content', 30 ); remove_action( 'woocommerce_checkout_terms_and_conditions', 'woocontracts_terms_fields', ); remove_action( 'woocommerce_before_checkout

Shipping methods only enabled in checkout page on Woocommerce

笑着哭i 提交于 2021-01-27 21:10:47
问题 On Woocommerce, we need to remove the shipping-methods from the Cart section an add it to the Checkout page only. Any track or help should be really appreciated? 回答1: There will be multiple ways to do it depending on the "why?" and on "for what?" you need this: 1) Hide shipping related from cart - The easiest way; add_filter( 'woocommerce_cart_ready_to_calc_shipping', 'disable_shipping_on_cart' ); add_filter( 'woocommerce_cart_needs_shipping', 'disable_shipping_on_cart' ); function disable

Get the value of a custom checkout field in woocommerce 3

我只是一个虾纸丫 提交于 2021-01-19 13:02:33
问题 In Woocommerce checkout, I am adding a custom checkout field and here is my code: add_action( 'woocommerce_before_order_notes', 'shipping_add_select_checkout_field' ); function shipping_add_select_checkout_field( WC_Checkout $checkout ) { $options = array_merge( [ '' => __( 'Nothing to select' ), ], city_zone() ); woocommerce_form_field( 'billing_country_zone', array( 'type' => 'select', 'class' => array( 'form-row-wide', 'address-field', 'update_totals_on_change' ), 'label' => __( 'City zone

Get the value of a custom checkout field in woocommerce 3

南笙酒味 提交于 2021-01-19 13:02:19
问题 In Woocommerce checkout, I am adding a custom checkout field and here is my code: add_action( 'woocommerce_before_order_notes', 'shipping_add_select_checkout_field' ); function shipping_add_select_checkout_field( WC_Checkout $checkout ) { $options = array_merge( [ '' => __( 'Nothing to select' ), ], city_zone() ); woocommerce_form_field( 'billing_country_zone', array( 'type' => 'select', 'class' => array( 'form-row-wide', 'address-field', 'update_totals_on_change' ), 'label' => __( 'City zone

Limit guest users to buy a particular product multiple times in the same week based on previous orders in WooCommerce

左心房为你撑大大i 提交于 2021-01-07 01:06:11
问题 I'm looking for a restriction if a guest user has bought a specific product 2 times in a week he must not be able to make another purchase of same product . Im looking to apply this restriction based on guest user's email and phone number. I've seen many posts related to that but all focus on registered users however i want to apply this restriction for guest users. This is the code I am currently using, unfortunately without the desired result function my_ip_checker() { $last_order = get

How should I change the woocommerce_form_field HTML Structure?

回眸只為那壹抹淺笑 提交于 2020-12-26 12:17:22
问题 I'm using WooCommerce: Add Checkout Fees Based on Custom Radio Button from businessbloomer My question is about woocommerce_form_field() which is used in part 1 // etc... echo '<div id="checkout-radio">'; echo '<h3>Customize Your Order!</h3>'; woocommerce_form_field( 'radio_choice', $args, $chosen ); echo '</div>'; // etc... The structure of the HTML that woocommerce_form_field( 'radio_choice', $args, $chosen ); outputs is <p class="form-row form-row-wide update_totals_on_change" id="radio