hook-woocommerce

Percentage discount based on user role and payment method in Woocommerce

巧了我就是萌 提交于 2019-12-02 04:58:11
问题 I was trying to make a code snippet for functions.php which would apply a discount of 2 % for cart totals when the role "subscriber" and the payment method "credit-card" are both selected. My progress so far function discount_when_role_and_payment(/* magic */) { global $woocommerce; if ( /* credit-card selected */ && current_user_can('subscriber') ) { /* get woocommerce cart totals, apply 2% discount and return*/ } return /*cart totals after discount*/; } add_filter( '/* magic */', 'discount

Show caption under product gallery in WooCommerce

旧巷老猫 提交于 2019-12-02 04:52:54
问题 I'm trying to show the caption text under the thumbnail in the product page gallery. I need to show the text because there are a lot images in the gallery and each thumb is a part of an engine and the name help the user. The code for the gallery in WooCommerce product page is: echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<li data-thumb="%s">%s%s<a href="%s" class="%s lightbox" data-rel="ilightbox[product]" data-caption="%s" title="%s" alt="%s"><i class="fa

Display cart item count in Woocommerce cart widget

时光毁灭记忆、已成空白 提交于 2019-12-02 03:25:23
I am trying to display the count of the items in the cart at the bottom or top of the Woocommerce cart widget. It seems that by default behaviour the cart widget does not do this when in the sidebar. I have researched SO and found the following answer , but it has a slightly different goal of adding individual subtotals. I have tried modifying it, by passing in WC()->cart->get_cart_contents_count() instead of WC()->cart->get_cart() to see if I can get the cart item count, but it's not displaying...any suggestions? Example of what I am trying to do: Code I have modified from the approved answer

Show caption under product gallery in WooCommerce

不想你离开。 提交于 2019-12-02 02:20:36
I'm trying to show the caption text under the thumbnail in the product page gallery. I need to show the text because there are a lot images in the gallery and each thumb is a part of an engine and the name help the user. The code for the gallery in WooCommerce product page is: echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<li data-thumb="%s">%s%s<a href="%s" class="%s lightbox" data-rel="ilightbox[product]" data-caption="%s" title="%s" alt="%s"><i class="fa-search-plus"></i></a></li>', $thumb_image, $image_html, $caption_html, $image_link, $image_class,

Add the product image to Woocommerce my account order view

ぃ、小莉子 提交于 2019-12-02 00:55:44
I would like to add image on my account view order pages in Woocommerce.some one I am able to get the image but the size is too large and I don't know where I need to add this code: <?php // Get a list of all items that belong to the order $products = $order->get_items(); // Loop through the items and get the product image foreach( $products as $product ) { $product_obj = new WC_Product( $product["product_id"] ); echo $product_obj->get_image(); } ?> Any help will be appreciated Here is the location on the View order pages, wher I would like to add the product image: The following hooked

Add custom user email to CC for specific Woocommerce email notification

眉间皱痕 提交于 2019-12-01 14:42:18
In Woocommerce I try to customize the code from this thread to add a custom email as "CC" email address in customer completed order email notification: /** * Function adds a BCC header to emails that match our array * * @param string $headers The default headers being used * @param string $object The email type/object that is being processed */ function add_cc_to_certain_emails( $headers, $object ) { // email types/objects to add cc to $cc_email = get_user_meta( $user_id, 'order_cc_email', true ); // MY CUSTOM CODE $add_cc_to = array( 'customer_completed_order', // Customer Processing order

Enable Woocommerce shop purchases only during a daily time range

非 Y 不嫁゛ 提交于 2019-12-01 13:46:08
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_time = time(); if ( $now_time > $start_time && $now_time < $end_time ) { remove_action( 'woocommerce

Display a custom message for guest users in Woocommerce checkout page

不羁的心 提交于 2019-12-01 13:45:56
can use hook (hack) in functions.php show custom message for guest users in woocommerce checkout page? Or from another way? i need show message when active enabled registration on the checkout page. in woocommerce account settings. or enable guest checkout in checkout settings tab. because when deactivate this option, and guest option. one message show in checkout page (from woocommerce language file) esay change from edit language files. I would show my custom message to visitors when options is active (enabled). In summary; my custom message show to unlogged users (visitors) and hide for

Process custom bulk action on admin Orders list in Woocommerce

萝らか妹 提交于 2019-12-01 12:37:28
I have added a custom action in my woocommerce orders page like shown below, and I also have a custom order field "number of meals". Now what I want is when I select the orders in bulk and use that custom action then count of number of meals should get decreased by 1. For example if order id 1 & 2 had 15 & 12 number of meals respectively then after using the action it should become 14 & 11… The screenshot of my orders page, the custom hook and the custom order field I created: My code: add_filter( 'bulk_actions-edit-shop_order', 'decrease_number_of_meals_by_1' ); function decrease_number_of

Add custom user email to CC for specific Woocommerce email notification

假装没事ソ 提交于 2019-12-01 12:14:31
问题 In Woocommerce I try to customize the code from this thread to add a custom email as "CC" email address in customer completed order email notification: /** * Function adds a BCC header to emails that match our array * * @param string $headers The default headers being used * @param string $object The email type/object that is being processed */ function add_cc_to_certain_emails( $headers, $object ) { // email types/objects to add cc to $cc_email = get_user_meta( $user_id, 'order_cc_email',