woocommerce

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 ( !

Restrict payment gateways based on taxonomy terms in WooCommerce checkout

家住魔仙堡 提交于 2021-02-10 18:49:09
问题 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 ( !

A non well formed numeric value encountered while using wc_price WooCommerce hook

给你一囗甜甜゛ 提交于 2021-02-10 17:38:04
问题 I have a simple function that used to work that I got online somewhere a few years back. It allows me to manually change the currency conversion rate for EUR (€, Euro). Problem now is this: Notice: A non well formed numeric value encountered in /wp-content/themes/theme/functions.php on line 82 Whereof the notice refers to this line: $new_price = $price * $conversion_rate; This is what I need help fixing. This is the complete code: function manual_currency_conversion( $price ) { $conversion

WooCommerce progressive quantity discount for specific product categories

烂漫一生 提交于 2021-02-10 15:56:51
问题 I was researching a method to give a progressive discount if you have more than 1 product in the cart. I found this thread and actually using this code: //Discount by Qty Product add_action( 'woocommerce_before_calculate_totals', 'quantity_based_pricing', 9999 ); function quantity_based_pricing( $cart ) { global $product; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return; // Define discount rules and thresholds and

Add a custom “Sale Price” column to admin products list in Woocommerce

那年仲夏 提交于 2021-02-10 15:56:08
问题 I am trying to add a Sale Price column to admin Products list in Woocommerce. Here is my code: add_filter( 'manage_edit-product_columns', 'onsale_product_column', 10); function onsale_product_column($columns){ $new_columns = []; foreach( $columns as $key => $column ){ $new_columns[$key] = $columns[$key]; if( $key == 'product_cat' ) { $new_columns['onsale'] = __( 'Sale Price','woocommerce'); } } return $new_columns; } add_action( 'manage_product_posts_custom_column', 'onsale_product_column

WooCommerce progressive quantity discount for specific product categories

余生长醉 提交于 2021-02-10 15:54:07
问题 I was researching a method to give a progressive discount if you have more than 1 product in the cart. I found this thread and actually using this code: //Discount by Qty Product add_action( 'woocommerce_before_calculate_totals', 'quantity_based_pricing', 9999 ); function quantity_based_pricing( $cart ) { global $product; if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return; if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 ) return; // Define discount rules and thresholds and

Change shipping method programmatically from existing WooCommerce order

余生颓废 提交于 2021-02-10 14:55:17
问题 My customers ar buying subscriptions through my woocommerce website. They receive the products each month but somethimes they want to change the shipping method. I don't find doc for doing it through php. I could change the values in post_meta , woocommerce_order_items and woocommerce_order_itemmeta but it's not a durable solution. 回答1: Here is the way to change an order "shipping" item programmatically for a new shipping method id (slug ) to be defined: // Here set your shipping method ID

Change shipping method programmatically from existing WooCommerce order

北慕城南 提交于 2021-02-10 14:53:48
问题 My customers ar buying subscriptions through my woocommerce website. They receive the products each month but somethimes they want to change the shipping method. I don't find doc for doing it through php. I could change the values in post_meta , woocommerce_order_items and woocommerce_order_itemmeta but it's not a durable solution. 回答1: Here is the way to change an order "shipping" item programmatically for a new shipping method id (slug ) to be defined: // Here set your shipping method ID