hook-woocommerce

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

那年仲夏 提交于 2019-11-27 02:10:21
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_price ) / $product->regular_price ) * 100 ); return $price . sprintf( __(' Save %s', 'woocommerce' ),

How to get order ID in woocommerce_email_headers hook

假装没事ソ 提交于 2019-11-26 21:56:26
问题 I am trying to set the email address when have a new order. And I stored the new email in wp_postmeta . How to get the $order_id when using woocommerce_email_headers ? I need to get the order_id to use it with get_post_meta() function. Here is my code: function techie_custom_wooemail_headers( $headers, $object) { $email = get_post_meta( $order_id, '_approver_email', true ); // Replace the emails below to your desire email $emails = array('eee@hotmail.com', $email); switch($object) { case 'new

Adding custom field to product category in WooCommerce

我是研究僧i 提交于 2019-11-26 20:54:01
问题 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 回答1: 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()

WooCommerce action hooks and overriding templates

情到浓时终转凉″ 提交于 2019-11-26 20:38:25
I have started to learn how to create templates with WooCommerce and I had faced with a little problem. For instance, in the php file content-single-product.php of Woocommerce plugin I have strings like that: <?php /** * woocommerce_single_product_summary hook. * * @hooked woocommerce_template_single_title - 5 * @hooked woocommerce_template_single_rating - 10 * @hooked woocommerce_template_single_price - 10 * @hooked woocommerce_template_single_excerpt - 20 * @hooked woocommerce_template_single_add_to_cart - 30 * @hooked woocommerce_template_single_meta - 40 * @hooked woocommerce_template

Saving a product custom field and displaying it in cart page

筅森魡賤 提交于 2019-11-26 17:08:24
问题 With WooCommerce and I am doing some customization in my functions.php file, to get a custom field value on Cart page. I add a custom field before add to cart: function add_name_on_tshirt_field() { echo '<table class="variations" cellspacing="0"> <tbody> <tr> <td class="label"><label for="color">Name On T-Shirt</label></td> <td class="value"> <input type="text" name="name-on-tshirt" value="" /> </td> </tr> </tbody> </table>'; } add_action( 'woocommerce_before_add_to_cart_button', 'add_name_on

Woocommerce: Which hook to replace deprecated “woocommerce_add_order_item_meta”

こ雲淡風輕ζ 提交于 2019-11-26 15:31:21
Need to add custom meta to order items. Googled it and most articles says to use "woocommerce_add_order_item_meta" hook. This hook is deprecated in the newest version 2.3.7. Someone, please tell me which hook to use instead. http://docs.woothemes.com/wc-apidocs/function-woocommerce_add_order_item_meta.html If you look at wc-deprecated-functions.php you will see /** * @deprecated */ function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) { return wc_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique ); } Basically, the function was renamed to wc

Customizing my-account addresses fields in Woocommerce 3

若如初见. 提交于 2019-11-26 14:33:12
问题 I would like to remove the form field billing_adress_2 within the template form-edit-addresses.php. To finish is it possible to reorder the form fields likes this: first_name - last_name email - phone company address_1 postcode city state This change I would like to apply it only on the page (templates) form-edit-addresses.php Any help is appreciated 回答1: In My account > Adresses section, the below hooked functions will: remove "Address 2" billing and shipping fields reorder billing and

WooCommerce action hooks and overriding templates

为君一笑 提交于 2019-11-26 06:38:25
问题 I have started to learn how to create templates with WooCommerce and I had faced with a little problem. For instance, in the php file content-single-product.php of Woocommerce plugin I have strings like that: <?php /** * woocommerce_single_product_summary hook. * * @hooked woocommerce_template_single_title - 5 * @hooked woocommerce_template_single_rating - 10 * @hooked woocommerce_template_single_price - 10 * @hooked woocommerce_template_single_excerpt - 20 * @hooked woocommerce_template

Woocommerce: Which hook to replace deprecated “woocommerce_add_order_item_meta”

我的梦境 提交于 2019-11-26 02:58:55
问题 Need to add custom meta to order items. Googled it and most articles says to use \"woocommerce_add_order_item_meta\" hook. This hook is deprecated in the newest version 2.3.7. Someone, please tell me which hook to use instead. http://docs.woothemes.com/wc-apidocs/function-woocommerce_add_order_item_meta.html 回答1: If you look at wc-deprecated-functions.php you will see /** * @deprecated */ function woocommerce_add_order_item_meta( $item_id, $meta_key, $meta_value, $unique = false ) { return wc