woocommerce

How do I add custom fields to the categories in Woocommerce?

萝らか妹 提交于 2021-02-08 10:25:53
问题 I have a woocommerce site that groups products within categories and displays them on the initial shop page. I want to add custom fields to the categories. Theory: On the home page is a search form, the user types in their postcode and the categories with the matching postcode details (which will be specified within the custom fields) are displayed. I don't need the custom fields to show on the shop page, I just need to be able to apply the matching postcodes in the backend. Please does

Woocommerce change the shipping cost related with the subtotal

倖福魔咒の 提交于 2021-02-08 10:00:35
问题 I would like to know how can i change the shipping cost for example: If subtotal is lower than 10€ then shipping cost is 4.5€ if subtotal is same or higher than 10€ then make the shipping cost 2.5€ 回答1: The right way of doing it is like this: add_filter( 'woocommerce_package_rates', 'woocommerce_package_rates', 10, 2 ); function woocommerce_package_rates( $rates, $package ) { $new_cost = ( WC()->cart->subtotal < 10 ) ? 4.5 : 2.5; foreach($rates as $key => $rate ) { $rates[$key]->cost = $new

Woocommerce Payment Method Detection in Checkout Page

十年热恋 提交于 2021-02-08 09:55:46
问题 I am using woocommerce plugin and braintree extension of woocommerce for payment. I have enabled both card and paypal payment of woocommerce braintree to checkout. I am trying to figure out how to know which payment gateway the user selects before user actually checkouts and pays. Any hooks under woocommerce or braintree to find either credit card radio button or paypal payment radio button is checked for payment. However i know we can detect the gateway used for the particular order after

Redirect logged in users from a specific page to Woocommerce my account page

♀尐吖头ヾ 提交于 2021-02-08 09:33:05
问题 In Woocommerce I am trying to find a solution for checking if a user is logged in on custom page and if so, redirect user to "My Account" page. Any help on this is appreciated. 回答1: Try the following, where you will replace 'some-page' by your real page ID, slug or name. The code will redirect for a defined specific page logged in users to the my account page: add_action('template_redirect', 'specific_logged_in_redirect'); function specific_logged_in_redirect() { if ( is_page('some-page') &&

Adding html to WooCommerce Store Notice using filters

与世无争的帅哥 提交于 2021-02-08 09:27:06
问题 I am trying to add a div wrapper around my WooCommerce Store Notice using a filter. And I also want to replace the dismiss link with a close icon. This is what I have so far and it doesn't really work how I want it to; add_filter('woocommerce_demo_store', 'demo_store_filter'); function demo_store_filter($text){ return str_replace( '<p class="woocommerce-store-notice demo_store">', '<div class="hello"><p class="woocommerce-store-notice demo_store"></p></div>', $text); } Here is the default

Refresh the page after product remove from cart Woocommerce

瘦欲@ 提交于 2021-02-08 09:24:25
问题 I am facing this issue in woocommerce. When product us removed from the cart, then update cart button disabled. And after the refresh page is working fine. I am trying this hook: woocommerce_cart_item_removed But its not working return nothing. 回答1: In the latest versions of Woocommerce there is a JavaScript callback trigger available as described in this commit: /** * Update the .cart_totals div with a string of html. * * @param {String} html_str The HTML string with which to replace the div

Refresh the page after product remove from cart Woocommerce

心不动则不痛 提交于 2021-02-08 09:23:06
问题 I am facing this issue in woocommerce. When product us removed from the cart, then update cart button disabled. And after the refresh page is working fine. I am trying this hook: woocommerce_cart_item_removed But its not working return nothing. 回答1: In the latest versions of Woocommerce there is a JavaScript callback trigger available as described in this commit: /** * Update the .cart_totals div with a string of html. * * @param {String} html_str The HTML string with which to replace the div

Move coupon field after checkout payment in Woocommerce?

前提是你 提交于 2021-02-08 09:16:57
问题 I want to move the coupon file after the checkout payment. This is what I have tried all ready: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form'); add_action( 'woocommerce_after_checkout_form', 'woocommerce_checkout_coupon_form' ); Now is currently after the checkout form. Thanks! 回答1: You should try this: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_review_order_before_payment',

Move coupon field after checkout payment in Woocommerce?

自古美人都是妖i 提交于 2021-02-08 09:16:49
问题 I want to move the coupon file after the checkout payment. This is what I have tried all ready: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form'); add_action( 'woocommerce_after_checkout_form', 'woocommerce_checkout_coupon_form' ); Now is currently after the checkout form. Thanks! 回答1: You should try this: remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_coupon_form', 10 ); add_action( 'woocommerce_review_order_before_payment',

Change user role based on WooCommerce yearly orders count

旧时模样 提交于 2021-02-08 09:14:06
问题 I'm trying to implement a feature where customers receive a new user role after a certain amount of orders have been made, but all those orders must have been made within the same year. I was able to assign the user role based on nth number of orders but can't seem to go beyond to where the date needs to be taken into consideration, can someone point me in the right direction or point out what I might be missing. This is what I have tried so far. function change_user_role_on_order_status