hook-woocommerce

Rename multiple order statuses in Woocommerce

不打扰是莪最后的温柔 提交于 2019-11-28 04:58:34
问题 I'm trying to rename multiple WooCommerce order status by editing my theme's functions.php file. I found some code posted here a couple years ago that works to change a single order status, but since I'm very inexperienced with php, I don't know how to expand on it to change multiple statuses. Ideally I'd also like to rename 'wc-processing' to 'Paid' and 'wc-on-hold' to 'Pending'. Here's the code I found to edit a single order status: function wc_renaming_order_status( $order_statuses ) {

Limit product short description length in Woocommerce

穿精又带淫゛_ 提交于 2019-11-28 04:41:03
问题 I'm using the following code on my WordPress site to shorten my description excerpt on WooCommerce and it works fine if I input my characters for 14 or less. As soon as I enter more than 14 characters it shows the full short description. add_action( 'woocommerce_after_shop_loop_item_title', 'lk_woocommerce_product_excerpt', 35, 2); if (!function_exists('lk_woocommerce_product_excerpt')) { function lk_woocommerce_product_excerpt() { $content_length = 14; global $post; $content = $post->post

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

扶醉桌前 提交于 2019-11-28 02:22:36
问题 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

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

大兔子大兔子 提交于 2019-11-28 02:10:01
问题 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 回答1: 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'

Replace woocommerce_add_order_item_meta hook in Woocommerce 3.4

我只是一个虾纸丫 提交于 2019-11-28 01:41:08
I have custom code use woocommerce_add_order_item_meta hook. But woocommerce 3.4.0 show error log: "woocommerce_add_order_item_meta is deprecated since version 3.0.0! Use woocommerce_new_order_item instead." How to fix it? Thank you very much. My code: // add data design to order function tshirt_order_meta_handler( $item_id, $values, $cart_item_key ) { if( WC()->session->__isset( $cart_item_key.'_designer' ) ) { wc_add_order_item_meta( $item_id, "custom_designer", WC()->session->get( $cart_item_key.'_designer') ); } } add_action( 'woocommerce_add_order_item_meta', 'tshirt_order_meta_handler',

How to add more custom field in Linked Product of Woocommerce

自古美人都是妖i 提交于 2019-11-27 22:45:58
问题 Thanks to all developers at StackOverflow. I want to add more fields in Linked Product Section of Woocommerce. The fields should be similar to Upsell/Crosssell. My code so far:- add_action( 'woocommerce_product_options_linked_product_data', 'woocom_general_product_data_custom_field' ); woocommerce_wp_text_input( array( 'id' => '_upsizing_products', 'label' => __( 'Upsizing Products', 'woocommerce' ), 'placeholder' => 'Upsizing Products', 'desc_tip' => 'true', 'description' => __( 'Select

WooCommerce Get Order Product Details Before Payment in Plugin

[亡魂溺海] 提交于 2019-11-27 18:42:00
问题 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

Saving a product custom field and displaying it in cart page

我与影子孤独终老i 提交于 2019-11-27 15:24:35
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_tshirt_field' ); function render_meta_on_cart_item( $title = null, $cart_item = null, $cart_item_key =

Customizing my-account addresses fields in Woocommerce 3

核能气质少年 提交于 2019-11-27 09:10:54
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 In My account > Adresses section, the below hooked functions will: remove "Address 2" billing and shipping fields reorder billing and shipping address fields reorder billing Email and phone fields (after first and last names) remove "Address 2"

Change Cart total price in WooCommerce

假装没事ソ 提交于 2019-11-27 03:35:22
问题 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