hook-woocommerce

Add “View Product” button below add to cart button in WooCommerce archives pages

天涯浪子 提交于 2019-11-29 09:02:07
Most of the articles on the internet are about How to remove / replace the "view product" or "read more" button. I couldn't find something related to allowing both buttons working together. I am interested in having both buttons working in parallel ( at the same time ). The first button to be displayed should be " View product " (to be opened on the same page) then underneath " Add to Cart " At the moment, my store only displays the Add to cart button. I am using Storefront theme ( + custom child theme ). Would anyone be so kind and tell me how to do this? Use this custom function hooked in

Show product star ratings and count below the price in Woocommerce archive pages [closed]

送分小仙女□ 提交于 2019-11-29 08:53:14
In woocommerce archive pages, I would like to move the ratings under the price. Is that possible? How can I make it? Here is What I would like: Any help is appreciated. My website link The following function will move ratings below the price in Woocommerce archives pages: add_action('woocommerce_after_shop_loop_item_title','change_loop_ratings_location', 2 ); function change_loop_ratings_location(){ remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_rating', 5 ); add_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_rating', 15 ); } Code

WooCommerce hook for order creation from admin

时光总嘲笑我的痴心妄想 提交于 2019-11-29 08:47:38
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_processed') && get_post_type($order_id) == 'shop_order' && validate_order($order_id)) { order_action($order_id)

WooCommerce Get Order Product Details Before Payment in Plugin

∥☆過路亽.° 提交于 2019-11-29 04:49:55
I need to display order details from cart before payment in plugin. I work on one plugin what connect woocommerce and an payment API and there I need to send array of product details like product ID, name, description, quantity and individual amount. My problem is that I can't find right hook to get all data properly. How can I get this data? Thanks UPDATE Here is update based on anwers for everyone who need it: add_action('woocommerce_checkout_process', 'woocommerce_get_data', 10); function woocommerce_get_data(){ $cart = array(); $items = WC()->cart->get_cart(); foreach($items as $i=>$fetch)

WooCommerce - Remove downloads from menu in my account page

柔情痞子 提交于 2019-11-28 16:43:01
问题 I would like to remove downloads menu from my account page . How can I do this? Is it any hook to remove a specific item from the menu? Thanks. 回答1: Go to WooCommerce > Settings > Advanced and remove the entry for Downloads in the Account endpoints section, just leave it blank. And the menu will not be visible anymore. 回答2: You will need this lightly customized this code snippet: function custom_my_account_menu_items( $items ) { unset($items['downloads']); return $items; } add_filter(

Hooks around add to cart for Woocommerce

微笑、不失礼 提交于 2019-11-28 12:51:07
I am running a WooCommerce store with WC Marketplace. What I am trying to achieve with the hook below is to prevent a new item being added to a basket if there is already a product in the basket from a different vendor. e.g. If a shopper adds product x from vendor y to his basket, if they were to add product a from vendor b, then the item will not be added and the user will be informed of the error. I have 2 questions: - firstly when does a hook run, is it before the main function fired or after? I have a hook for the function woocommerce_add_to_cart . So I want to know will the hook fire

Change Cart total price in WooCommerce

白昼怎懂夜的黑 提交于 2019-11-28 12:26:21
I am running into issues with the cart total only displaying 0 Essentially what I am trying to do is only accept a deposit total of a certain amount after all cart items have been added to the carts subtotal. So for example if the customer adds $100 worth of items, they would only pay $10 initially or (10%) of the subtotal as the total value. I took the code from here: Change total and tax_total Woocommerce and customize it this way: add_action('woocommerce_cart_total', 'calculate_totals', 10, 1); function calculate_totals($wc_price){ $new_total = ($wc_price*0.10); return wc_price($new_total);

Adding custom field to product category in WooCommerce

◇◆丶佛笑我妖孽 提交于 2019-11-28 09:06:42
How can I add custom fields to product category? I have added custom field to product but I cant find any extension which provide facility to add custom field to product category. Please help You can add custom fields to WooCommerce product category by using following action : product_cat_add_form_fields product_cat_edit_form_fields edited_product_cat create_product_cat UPDATED on 17-Feb-2017 For WP version 4.4 and above. As of WordPress 4.4, update_term_meta() and get_term_meta() functions have been added. This means that now we don't have to save the data in wp_options table anymore, rather

Process custom bulk action on admin Orders list in Woocommerce

时间秒杀一切 提交于 2019-11-28 05:46:37
问题 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

Exclude related products ids in Woocommerce

北战南征 提交于 2019-11-28 05:34:32
问题 function woocommerce_output_related_products() { $args = array( 'posts_per_page' => 4, 'columns' => 4, 'orderby' => 'rand', // @codingStandardsIgnoreLine. 'post__not_in' => array(502,281) ); woocommerce_related_products( apply_filters( 'woocommerce_output_related_products_args', $args ) ); } I copied this function from includes/wc-template-functions.php into my theme's functions.php To verify that my changes would work I changed the posts_per_page to 3 and it queried only 3 instead of 4. I