hook-woocommerce

Woocommerce: delete “additional information” tab

杀马特。学长 韩版系。学妹 提交于 2019-12-11 06:19:33
问题 Two things I am trying to do on the product pages of this website: https://lovesometea.com/product/green-coconut/ 1) Delete "additional information" tab 2) Add Attribute "Size" above the product description To delete the "additional information" tab, I have been following this: https://idevie.com/tutorials/how-to-make-woocommerce-product-attributes-more-prominent So this is what I did: 1) Added a custom plug-in and activated it - http://code.tutsplus.com/tutorials/making-woocommerce-product

Getting the value of the product's id value (_product_id) after the payment in WooCommerce

邮差的信 提交于 2019-12-11 06:09:53
问题 I want to get the value of _product_id on the payout page ( thankyou.php ), can somebody help me with this. I have attached an image of the field I need exactly that value 回答1: You can use woocommerce_thankyou hook to get the product ID's in thankyou page function wh_getProductIds($order_id) { //getting order object $order = wc_get_order($order_id); $product_id_arr = []; //getting all line items foreach ($order->get_items() as $item) { $product = $item->get_product(); $product_id_arr =

woocommerce : Need to save cart item meta of the each product to orders

…衆ロ難τιáo~ 提交于 2019-12-11 06:03:25
问题 currently i add product to the cart by $woocommerce->cart->add_to_cart( 21, 1, 0, $item,$cart_item_data) now product with id 21 is added to cart . I save many details in $cart_item_data .What i want is when the order is created for this cart product then the $cart_item_data need to save to the db , and in the order section of admins i can see the details of each product with this $cart_item_data . I know how to save order item meta . add_action('woocommerce_add_order_item_meta',function($item

How to add custom hooks to a custom plugin for Woocommerce

北城以北 提交于 2019-12-11 05:46:02
问题 We have develop a custom plugin for Woocommerce payment integration and we need to add woocommerce hooks, in our plugin file without including it in Theme folder's function.php . How can we Add custom hooks to our plugin that we can invoke from function.php file? is there any workaround for it? (when we add custom woocommerce hooks and action code in function.php file in wordpress theme then code work fine but we need it in our custom plugin file.) Any help will be highly appreciated. 回答1:

Wordpress # to create product link

China☆狼群 提交于 2019-12-11 05:44:06
问题 I'm working on redoing a clients website using wordpress. Their previous developer who wrote the website from scratch, made a products sku/product id with a hash/pound sign '#' in front of the sku/product id number in the text editting of the product in the admin section would create a link to the existing product. I was wondering what language and what the code might look like so I could successfully do essentially the same thing. I've already created in WooCommerce a uniform shortlink to

Woocommerce, update price when added by admin via wp-admin

 ̄綄美尐妖づ 提交于 2019-12-11 05:16:36
问题 I would like to set a 50% discount when and only when the admin adds a product to the existing order via the admin area. I've tried with this: function admin_set_custom_price( $item, $item_id ) { $item->set_subtotal( ( ( ( 100 - 50 ) * $item->get_subtotal() ) / 100 ) ); $item->set_total( ( ( ( 100 - 50 ) * $item->get_total() ) / 100 ) ); $item->apply_changes(); $item->save(); return $item; } add_filter( 'woocommerce_ajax_order_item', 'admin_set_custom_price', 10, 2 ); And the result is that

Enable back price suffix to a function that display customized product prices in WooCommerce

删除回忆录丶 提交于 2019-12-11 04:27:12
问题 I am using "Enable sale price for logged users and regular price for unlogged users in Woocommerce" first function code, that hides sales price. That way I can use sales price and regular price for logged in vs none logged in users and it Works like a charm. The Problem I have is that it also kills the woocommerce_price_suffix field from the settings and I want to include it in my function, but don't know how. 回答1: The following will add back the price suffix: //Variable and simple product

Save and display order custom meta data in Woocommerce 3+

让人想犯罪 __ 提交于 2019-12-11 02:42:17
问题 A while back my partner helped me to add a custom field to our checkout page, we wanted to ask people "How did you hear about us?" when they booked for our events. We put it together but shortly after we stopped being able to see the results properly. In the "New Order" emails sent to the admin, the label 'How did you hear about us' appears, but with no answer. In the order page, it appears in two places: 1) under the Billing info. The label is there. Value is: Array 2) under "Custom Fields"

Adding a hidden checkout field in WooCommerce?

人盡茶涼 提交于 2019-12-11 02:04:50
问题 I want to include a link to a profile of the current user who submitted a checkout form through WooCommerce. That is, to place automatically a current user’s author link like this in the hidden field: example.com/author/username I want to achieve this by adding a hidden field in checkout form. So to get a link I would write something likes this: <?php $currentUser = get_current_user_id(); $user = get_user_by( 'id', $currentUser ); $userUrl = get_bloginfo( 'home' ) . '/author/' . $user->user

Product custom checkbox option that changes Woocommerce cart item price

亡梦爱人 提交于 2019-12-11 01:06:15
问题 The following code displays a custom checkbox before add to cart button on single product pages: add_action( 'woocommerce_before_add_to_cart_button', 'output_custom_text_field', 0 ); function output_custom_text_field() { //Lots of code then: <input type="checkbox" id="option1" name="option1"> } Now I would like to trap/capture this checkbox option in Woocommerce session and then make a custom price calculations in the following code: function final_cart_update( $cart_object ) { foreach (