hook-woocommerce

How to insert Google Merchant Review JS code in WooCommerce Order Complete page

主宰稳场 提交于 2019-12-19 11:45:07
问题 I want to complete the variables the Google Merchant Review codes asks to be completed on the checkout page: <script src="https://apis.google.com/js/platform.js?onload=renderOptIn" async defer></script> <script> window.renderOptIn = function() { window.gapi.load('surveyoptin', function() { window.gapi.surveyoptin.render( { "merchant_id": mymerchantid, "order_id": "ORDER_ID", "email": "CUSTOMER_EMAIL", "delivery_country": "COUNTRY_CODE", "estimated_delivery_date": "YYYY-MM-DD" }); }); } <

Enable Woocommerce shop purchases only during a daily time range

拥有回忆 提交于 2019-12-19 11:03:23
问题 I am trying to create a shut down between two times, but it's not working. Nothing is happening. Here's the code I'm using: add_action( 'woocommerce_before_single_product_summary', 'shop_closed' ); add_action( 'woocommerce_before_shop_loop', 'shop_closed' ); function shop_closed() { global $woocommerce; date_default_timezone_set('Europe/London'); $start_time = mktime('16', '59', '59', date('m'), date('d'), date('Y')); $end_time = mktime('08', '59', '59', date('m'), date('d'), date('Y')); $now

WooCommerce Cart - Dynamic Price variable pass into custom price hook

三世轮回 提交于 2019-12-19 09:56:39
问题 I am getting the dynamic custom price in a variable that I want to pass to the hooked function in woocommerce_before_calculate_totals hook in cart. But it isn't working. This is my code: $add=200; //I want to pass this variable in add_action hook add_action( 'woocommerce_before_calculate_totals', 'add_custom_total_price'); function add_custom_total_price($cart_object) { global $woocommerce; $custom_price =$add; // This is my custom price foreach ( $cart_object->cart_contents as $key => $value

Automatic text in short description of WooCommerce products

非 Y 不嫁゛ 提交于 2019-12-19 04:34:07
问题 I am trying to create an automatic text in the description of the WooCommerce articles and put "article only available in the store." I thought about putting it inside a function like this: add_filter ('woocommerce_short_description', 'in_single_product', 10, 2); function in_single_product () { echo '<p> article only available in the store. </ p>'; } But this replace the text that is already written in the short description of the product. If I have not put text, nothing appears. Is possible

woocommerce change price in checkout and cart page

一世执手 提交于 2019-12-18 06:57:47
问题 With woocommerce, in my website I'd like to add in the cart page a select input where the user can select a value between two options, and depending on this value I will change the price. so far, I could get the total and change it using this : function action_woocommerce_before_cart_totals( ) { global $woocommerce; $woocommerce->cart->total = $woocommerce->cart->total*0.25; var_dump( $woocommerce->cart->total);}; The issue is that when I go to checkout page it doesn't take the total

WooCommerce hook for order creation from admin

别说谁变了你拦得住时间么 提交于 2019-12-18 05:20:34
问题 In my custom plugin (working in WooCommerce 2.6.x and 3.x), I need to get the order ID when a new order is created. I tried different hooks but they work only when the customer creates an order and not when an order is created from admin. I tried: woocommerce_new_order woocommerce_thankyou woocommerce_checkout_order_processed woocommerce_checkout_update_order_meta Update Finally I used this: add_action('wp_insert_post', function($order_id) { if(!did_action('woocommerce_checkout_order

Change the add to cart text for a specific product category in Woocommerce 3

谁都会走 提交于 2019-12-18 04:30:15
问题 I want to change the add to cart text on product archives on specific categories only. For example, on preorder category i want instead of add to cart text, to be Preorder . I don't know how to identify Preorder category in the below function. add_filter( 'add_to_cart_text', 'woo_archive_custom_cart_button_text' ); // < 2.1 function woo_archive_custom_cart_button_text() { return __( 'Preorder', 'woocommerce' ); } 回答1: Update: add_to_cart_text hook is obsolete & deprecated. It is replaced in

Display the discounted percentage near sale price in Single product pages for WC 3.0+

故事扮演 提交于 2019-12-17 05:12:24
问题 I had this code in function.php of my theme to display the percentage after price and it was working fine in WooCommerce v2.6.14. But this snippet doesn't work anymore on WooCommerce version 3.0+. How can I fix that? Here is that code: // Add save percent next to sale item prices. add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 ); function woocommerce_custom_sales_price( $price, $product ) { $percentage = round( ( ( $product->regular_price - $product->sale

Replace Add To Wishlist text with Heart icon WooCommerce

十年热恋 提交于 2019-12-14 02:15:08
问题 Hi friends I am using YITH WooCommerce Wishlist plugin by default Add To Wishlist text is coming, I want to replace the Button text with icon. is it possible through any hook? Thanks in advance 回答1: 'Add To Wishlist' text you can replace navigating Wordpress Dashboard --> YITH Plugins --> Wishlist page. To customize button, copy the file plugins/yith-woocommerce-wishlist/templates/add-to-wishlist-button.php to your-theme/woocommerce directory (If haven't created yet, create) and apply your

Getting the correct variation price from order items in Woocommerce 3

房东的猫 提交于 2019-12-13 20:12:45
问题 Im trying to get the correct price for each item variation however it only seems to be getting the first price of that product variation. Not sure how to solve this. Code: $query = new WC_Order_Query( array( 'status' => 'on-hold', 'orderby' => 'date', 'order' => 'DESC', 'return' => 'ids', ) ); $order_ids = $query->get_orders(); foreach( $order_ids as $order_id ) { $order = new WC_Order($order_id); foreach ($order->get_items() as $item_id => $item_obj) { $_product = wc_get_product($item_obj[