woocommerce

Change “add to cart” text if a user has bought specific products in WooCommerce

点点圈 提交于 2021-02-05 12:13:34
问题 I wanted to know if there is a way to replace the woo-commerce "add to cart" button with custom text and url for a specific product if the user has bought that specific product. and I want it happens everywhere (on shop page,product page , ...) 回答1: Try the following that will change the product "add to cart" text if that product has already been bought by the customer on single product pages and archive pages add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_text', 900,

Woocommerce: How to show Product Attribute name on title when in a category page and “filtering” products via '?pa_attribute=' on address bar

荒凉一梦 提交于 2021-02-05 11:20:06
问题 So I have a product attribute (for ex.: color) and I can show only products inside a Category that have that attribute by using, for ex., ?pa_color=red in the address bar, so if I go '*www.mysite.com/product-category/t-shirts/?pa_color=red*' I'll have only t-shirts that have the color red as an attribute. That works. The problem is, when I do that "filtering", the page title (above the product listing) still says only "T-Shirts" , it does not specify that it's only showing Red T-shirts and it

Set “flat rate” shipping method as default in woocommerce

本秂侑毒 提交于 2021-02-05 11:12:24
问题 I have a woocommerce website and I have set 2 shipping methods: - Flat Rate - Local pickup I would like to set the "Flat rate" shipping method as default (selected) in the cart or checkout page. Any help should be appreciated. 回答1: 1) You can use the following code (to set "flat rate" shipping method as default) In cart page: add_action( 'woocommerce_before_cart', 'set_default_chosen_shipping_method', 5 ); function set_default_chosen_shipping_method(){ // if( count( WC()->session->get(

Set “flat rate” shipping method as default in woocommerce

僤鯓⒐⒋嵵緔 提交于 2021-02-05 11:10:23
问题 I have a woocommerce website and I have set 2 shipping methods: - Flat Rate - Local pickup I would like to set the "Flat rate" shipping method as default (selected) in the cart or checkout page. Any help should be appreciated. 回答1: 1) You can use the following code (to set "flat rate" shipping method as default) In cart page: add_action( 'woocommerce_before_cart', 'set_default_chosen_shipping_method', 5 ); function set_default_chosen_shipping_method(){ // if( count( WC()->session->get(

Add a product subtitle in Woocommerce archives pages

冷暖自知 提交于 2021-02-05 09:23:31
问题 I can add a subtitle to my product title by adding the following code to single-product/title.php: the_title( '<h1 class="product_title entry-title">', '</h1>' ); echo "<p>My subtile</p>"; The problem is that this only appears on the product page. Not on other views such as the shop view: I have looked everywhere and cannot find out where to modify the title for other views of the WooCommerce store? 回答1: Updated - To add a product subtitle in archives pages like shop use the following: add

Get orders by meta data via WooCommerce WC_Order_Query

旧城冷巷雨未停 提交于 2021-02-05 09:10:27
问题 How can I get a WooCommerce order by its number (instead of its ID)? I tried using wc_get_orders with custom args, like: wc_get_orders( array( 'number' => '1000' ) ); But it doesn't seem to work. Thanks! 回答1: Order numbers functionality is really enabled through a third party plugin in WooCommerce… Then in this case a new meta_key exist in wp_postmeta database table for shop_order WooCommerce post type which is _order_number . So this parameter doesn't exist by default when using wc_get

How to show a product custom field (custom SKU) in WooCommerce orders

瘦欲@ 提交于 2021-02-05 08:51:20
问题 Is there a way to display my custom SKU under each product on the WooCommerce order page? The custom sku displays fine when I edit the product, but it does not display in the order page for the product. I need this information to show on the order so that Zapier can match it with the Visma Account Software ArticleID of the product. This attempt is based on the solution How to add a (second) custom sku field to WooCommerce products? // Add Custom SKU Field function my_add_custom_sku() { $args

Conditionally adding or removing a free product in cart

青春壹個敷衍的年華 提交于 2021-02-05 08:47:09
问题 I've a function in woocommerce that add automatically to cart a free gift. I would like to add this based on minimum quantity of 15 i've this code that works, but when i update the cart don't remove the item if the quantity is not 15. How I can automatic remove product when I update the cart if total id different to 15 ? } //add_action( 'init', 'wcsg_add_product_to_cart' ); add_action( 'wp_loaded', 'wcsg_add_product_to_cart', 99 ); function wcsg_add_product_to_cart() { if ( ! is_admin() ) {

Conditionally adding or removing a free product in cart

▼魔方 西西 提交于 2021-02-05 08:47:06
问题 I've a function in woocommerce that add automatically to cart a free gift. I would like to add this based on minimum quantity of 15 i've this code that works, but when i update the cart don't remove the item if the quantity is not 15. How I can automatic remove product when I update the cart if total id different to 15 ? } //add_action( 'init', 'wcsg_add_product_to_cart' ); add_action( 'wp_loaded', 'wcsg_add_product_to_cart', 99 ); function wcsg_add_product_to_cart() { if ( ! is_admin() ) {

Change specific payment gateway title in WooCommerce

大城市里の小女人 提交于 2021-02-05 08:36:07
问题 I need to change the Woocommerce payment gateway names, not the ones hat are displayed on the frontend(this can easily be achieved in the settings) but the inernatl titles Woo is using. In class-wc-gateway-cheque.php for example I found this $this->id = 'cheque'; but simply changing the name there did not work. How can I change the name Woocommerce is using internally for this payment method? 回答1: So what you can do instead is to copy the source code from WC_Gateway_Cheque Class to a plugin