hook-woocommerce

Add custom content for a specific product on WooCommerce single product pages

孤街醉人 提交于 2020-02-04 03:24:06
问题 In Woocommerce, How can I add a custom content for a specific product on single product pages? Here is an explicit screen shot: 回答1: As your screenshot is not so clear on where you want this custom content you have 2 options: 1) Under the product price With this custom function hooked in woocommerce_before_single_product_summary action hook you can add some custom content to a specific product ID (to be defined in the function) this way: add_action( 'woocommerce_single_product_summary', 'add

Save WooCommerce order item custom fields sum as a new meta data

空扰寡人 提交于 2020-02-02 12:49:29
问题 When a particular product is ordered in this WooCommerce store, two meta values are added to the order. The two fields that store the meta values are located in wp_woocommerce_order_itemmeta The meta keys are : quantity assemblycost I want to create a new custom field programmatically when a new order is placed and set the value of this new field equal to quanity * assemblycost if the meta key assemblycost exists for the product that has been ordered. After some research I discovered that

How to remove order total from cart and checkout page woocommerce

主宰稳场 提交于 2020-01-30 07:41:28
问题 I would like to remove order total block on cart and checkout page. I am not able to find any action or filter to remove order total. I don't want to use css to hide this column. 回答1: Using hooks: 1) Remove cart totals: // On cart page add_action( 'woocommerce_cart_collaterals', 'remove_cart_totals', 9 ); function remove_cart_totals(){ // Remove cart totals block remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 ); // Add back "Proceed to checkout" button (and hooks

How to remove order total from cart and checkout page woocommerce

喜你入骨 提交于 2020-01-30 07:40:02
问题 I would like to remove order total block on cart and checkout page. I am not able to find any action or filter to remove order total. I don't want to use css to hide this column. 回答1: Using hooks: 1) Remove cart totals: // On cart page add_action( 'woocommerce_cart_collaterals', 'remove_cart_totals', 9 ); function remove_cart_totals(){ // Remove cart totals block remove_action( 'woocommerce_cart_collaterals', 'woocommerce_cart_totals', 10 ); // Add back "Proceed to checkout" button (and hooks

Disable Woocommerce add to cart button if the product is already in cart

假如想象 提交于 2020-01-28 02:30:18
问题 I am trying to set the functionality in Woocommerce on the Add to Cart button to only allow a particular product to be added once to the Cart. Once a particular product has been added to cart the first time, the Add to Cart needs to be hidden. In the cart I can have any number of products - just a max of quantity 1 for each product. I was doing research and saw that I can use woocommerce_add_to_cart_validation hook. But have no idea how to start off. How can I allow a particular product to be

Add Product SKU to Product Title in Woocommerce single product page & shop page

社会主义新天地 提交于 2020-01-22 02:49:06
问题 i want to add product sku to actual product title. for example, if product name is "Dress design" & product sku is "2790" the new product title should be "Dress design - 2790". i had tried following code. but this code replaces the product title by the product SKU on single product pages. add_action( 'woocommerce_single_product_summary', 'replace_product_title_by_product_sku', 4 ); function replace_product_title_by_product_sku() { global $product; if ( $product->get_sku() ) { remove_action(

Customize content in WooCommerce admin quick order preview

耗尽温柔 提交于 2020-01-21 09:26:07
问题 I am new to WordPress and I am using WooCommerce plugin in my project where I need to modify some of template files and some of core files of WooCommerce. I have created child theme and created woocommerce folder inside my child theme and hence I can create/modify template files there which customizations won't be lost during WooCommerce plugin updates. But as I have read on some articles, modifying core files of WooCommerce is not recommended. I have customized in WooCommerce plugin this

Add Text under Single Product Short Description in Woocommerce

我的梦境 提交于 2020-01-20 07:09:50
问题 I want to add some Global Text immediately under the Product Short Description in Woo Commerce, before the product options. I can change the file directly, but of course as soon as it updates it gets over written. Is there another way of doing this? 回答1: Update 2: There is 3 different ways, using hooks: 1) Adding your custom text at the end of the short description content, (not for variable products ): add_filter( 'woocommerce_short_description', 'add_text_after_excerpt_single_product', 20,

Add Text under Single Product Short Description in Woocommerce

≯℡__Kan透↙ 提交于 2020-01-20 07:09:17
问题 I want to add some Global Text immediately under the Product Short Description in Woo Commerce, before the product options. I can change the file directly, but of course as soon as it updates it gets over written. Is there another way of doing this? 回答1: Update 2: There is 3 different ways, using hooks: 1) Adding your custom text at the end of the short description content, (not for variable products ): add_filter( 'woocommerce_short_description', 'add_text_after_excerpt_single_product', 20,

How to display the regular price and sale price in single product and loop pages? [duplicate]

随声附和 提交于 2020-01-16 18:27:53
问题 This question already has an answer here : Display the discounted percentage near sale price in Single product pages for WC 3.0+ (1 answer) Closed 2 years ago . I had this code in function.php of my child theme to display the regular price and sale price and it was working fine in WooCommerce v2.6.14. But this snippet doesn't work anymore on WooCommerce version 3.2.3. How can I fix that? Here is that code: add_filter( 'woocommerce_sale_price_html', 'woocommerce_custom_sales_price', 10, 2 );