woocommerce

Add a custom class to variation options displaying “Out Of Stock” in Woocommerce

守給你的承諾、 提交于 2021-02-11 04:54:10
问题 I'm using "How to add variation stock status to Woocommerce product variation dropdown" answer code to show the text "In Stock" or "Out of stock" according to the stock status of the variation. This is what I get: I need to add a custom class only to these variants that showing text "Out of Stock". how can I do it? Emanuele 回答1: The following code will add the class outofstock to <option> html tag when the variation is "Out of Stock": // Function that will check the stock status and display

Display WooCommerce custom product field meta data in Cart and on Checkout

南笙酒味 提交于 2021-02-10 23:39:52
问题 I've created a custom product field (admin). The field works fine and it saves the data just fine. What I am having problems with it is adding the meta data to the cart and checkout. I get no errors (debug turned on in wp-config ), no notices -- nothing. In the cart and on checkout, no data is shown. This is my code: add_action( 'woocommerce_product_options_general_product_data', 'product_delivery_time' ); function product_delivery_time(){ global $woocommerce, $post; echo '<div class="product

Setting a tax class based on specific coupon in Woocommerce

杀马特。学长 韩版系。学妹 提交于 2021-02-10 20:52:05
问题 This has been answered a while back but the filter is not working anymore. Not sure if it is deprecated or not. I am using both filters: woocommerce_product_tax_class woocommerce_product_get_tax_class My function looks like: function wc_diff_rate_for_user( $tax_class, $product ) { $tax_class = "Zero rate"; return $tax_class; } add_filter( 'woocommerce_product_tax_class', 'wc_diff_rate_for_user', 1, 2 ); How can I set a tax class based on specific coupon in Woocommerce? 回答1: Since Woocommerce

Custom Layout for Single Product page - Woocommerce

浪尽此生 提交于 2021-02-10 20:49:37
问题 I am trying to create a custom layout for one of our product pages in Woocommerce. I have searched and followed so many tutorials, but none are working for me. I copied 'single-product.php' and placed it into my active child theme in the folder 'woocommerce'. I then duplicated this and renamed it 'single-product-landing.php'. I then placed the following code into my functions.php page: add_filter( 'template_include', 'custom_single_product_template_include', 10 ); function custom_single

Custom Layout for Single Product page - Woocommerce

蓝咒 提交于 2021-02-10 20:47:45
问题 I am trying to create a custom layout for one of our product pages in Woocommerce. I have searched and followed so many tutorials, but none are working for me. I copied 'single-product.php' and placed it into my active child theme in the folder 'woocommerce'. I then duplicated this and renamed it 'single-product-landing.php'. I then placed the following code into my functions.php page: add_filter( 'template_include', 'custom_single_product_template_include', 10 ); function custom_single

Custom Layout for Single Product page - Woocommerce

半城伤御伤魂 提交于 2021-02-10 20:46:34
问题 I am trying to create a custom layout for one of our product pages in Woocommerce. I have searched and followed so many tutorials, but none are working for me. I copied 'single-product.php' and placed it into my active child theme in the folder 'woocommerce'. I then duplicated this and renamed it 'single-product-landing.php'. I then placed the following code into my functions.php page: add_filter( 'template_include', 'custom_single_product_template_include', 10 ); function custom_single

How do I find the shipping class id in WooCommerce?

断了今生、忘了曾经 提交于 2021-02-10 20:40:36
问题 Using Hide shipping method for specific shipping classes in woocommerce answer code, I'm trying to hide shipping options based on shipping class. Large items and small items have their own shipping class on our website and we only want to offer express shipping on small items. add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 ); function hide_shipping_method_based_on_shipping_class( $rates, $package ) { if ( is_admin() && ! defined( 'DOING_AJAX' )

How do I find the shipping class id in WooCommerce?

喜你入骨 提交于 2021-02-10 20:39:14
问题 Using Hide shipping method for specific shipping classes in woocommerce answer code, I'm trying to hide shipping options based on shipping class. Large items and small items have their own shipping class on our website and we only want to offer express shipping on small items. add_filter( 'woocommerce_package_rates', 'hide_shipping_method_based_on_shipping_class', 10, 2 ); function hide_shipping_method_based_on_shipping_class( $rates, $package ) { if ( is_admin() && ! defined( 'DOING_AJAX' )

WooCommerce check if free shipping is activated

倖福魔咒の 提交于 2021-02-10 19:49:36
问题 I want to show if free shipping is activated on my WooCommerce cart, to tell people "Hey, you've got free shipping!". Free shipping can be activated by either order amount or a coupon. I have tried this code, but it returns an empty array. global $woocommerce; $woocommerce->shipping->get_shipping_methods(); Otherwise I could have checked if free_shipping was set. Hope you all have some great ideas how to get this working :) 回答1: global $woocommerce; $shipping_methods = $woocommerce->shipping-

Save WooCommerce Order details in custom table

眉间皱痕 提交于 2021-02-10 19:41:32
问题 I have created a custom database in table order-master in which I will save WooCommerce order total amount , shipping charges and token . For this, I have edited paypemts.php file, code is below: <?php include_once($_SERVER['DOCUMENT_ROOT'].'/canadiapharma.com/wp-config.php' ); global $woocommerce; global $wpdb; echo '<h3>Custom Calculation :</h3>'; $amount_2 = $woocommerce->cart->get_cart_total(); $ship_raw = floatval( preg_replace( '#[^\d.]#', '', $woocommerce->cart->get_cart_shipping_total