wordpress

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' )

Initialize WordPress environment in a script to be run by a cron job

℡╲_俬逩灬. 提交于 2021-02-10 20:36:27
问题 I have to run a custom PHP script which I want to run by a cron job. Within that script, I need wordpress functions to insert users into WordPress table. My script is on the root directory of the wordpress installation. My script is starting with: require( dirname( __FILE__ ) . '/wp-load.php' ); If I run the script directly in the browser then my functions and everything else works with no errors. But when the cron hits it apparently does not work. Nothing that is supposed to happen happens.

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

Save WooCommerce Order details in custom table

走远了吗. 提交于 2021-02-10 19:41:31
问题 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

Display specific product attribute in Woocommerce single product pages below price

余生长醉 提交于 2021-02-10 19:35:26
问题 In woocommerce, If a specific product attribute has a value, then I would like to display its corresponding text/value on product single product pages under the price. How to check if a specific product attribute has a value? How to get a specific product attribute name and value to display it in single product pages? 回答1: The following will display a specific product attribute label name + values under the price in single product pages only if it has a value. This can be done using WC

Restrict payment gateways based on taxonomy terms in WooCommerce checkout

妖精的绣舞 提交于 2021-02-10 18:50:27
问题 In my WooCommerce store I want to restrict and show payment gateway(cheque) only if the product has particular product category with the category ID "266". Now I have this snippet but it does the opposite - it disabled the gateway on the checkout for particular product category: add_filter( 'woocommerce_available_payment_gateways', 'bbloomer_unset_gateway_by_category' ); function bbloomer_unset_gateway_by_category( $available_gateways ) { if ( is_admin() ) return $available_gateways; if ( !