hook-woocommerce

Re-calculate totals after setting cart item prices in Woocommerce

佐手、 提交于 2019-12-11 00:32:13
问题 How i can change subtotal price after i changed the price of product by the set_price() method? Now it is calculate the total cost at old prices in review-order.php. cart.php foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) { ... $_product = apply_filters( 'woocommerce_cart_item_product', $cart_item['data'], $cart_item, $cart_item_key ); $product_id = apply_filters( 'woocommerce_cart_item_product_id', $cart_item['product_id'], $cart_item, $cart_item_key ); ... $_product->set

Display a custom notice before all default notices in Woocommerce checkout page

不羁岁月 提交于 2019-12-11 00:32:09
问题 I use the following below code for show custom message to un-logged woocommerce users (visitors) in checkout page add_action('woocommerce_before_checkout_form', 'my_custom_message'); function my_custom_message() { if ( ! is_user_logged_in() ) { wc_print_notice( __('This is my custom message'), 'notice' ); } } top code recive this forum, from mr @loictheaztec my before question link below: Display a custom message for guest users in Woocommerce checkout page I would like to change woocommerce

woocommerce sort products by in stock and out of stock in front-end

那年仲夏 提交于 2019-12-10 18:55:08
问题 I want to show in stock products first in products category or if possible in any where and then I want to display out of stock products too after them in Woocommerce Actually there are many products which have not quantity number but those are in stock, So it is need to check in stock status, But I prefer to have more quantities first How can I make a force for current sorting in such case? Thank you very much 回答1: Using this code: <?php /** * Order product collections by stock status,

remove_action From PHP Class

点点圈 提交于 2019-12-10 18:17:37
问题 I'm attempting to remove an action and add it with a different priority. Below are all the code snippets that assist in generating a Message: Include required frontend files private function frontend_includes() { require_once( $this->get_plugin_path() . '/includes/wc-memberships-template-functions.php' ); require_once( $this->get_plugin_path() . '/includes/class-wc-memberships-shortcodes.php' ); WC_Memberships_Shortcodes::initialize(); $this->frontend = $this->load_class( '/includes/frontend

Checkbox field that add a subscription product and change prices of other products

依然范特西╮ 提交于 2019-12-10 12:26:07
问题 In Woocommerce checkout section, I am trying to add a checkbox that adds an additional subscription product. It is working fine and I took help from here One more requirement is that if there are other products in the cart then I want to change each product prices based on custom fields and new prices should display in the checkout. Thanks in advance. I used this code and working fine but product price is not changing in PayPal payment page. // Display a custom checkout field add_action(

Get all active users for a membership plan in WooCommerce

对着背影说爱祢 提交于 2019-12-10 11:18:46
问题 I am Using Wordpress version 4.9.4 with WooCommerce an WooCommerce Memberships plugin. How can I get all users for specific membership plan ($memberships)? Is there a hook or should I use raw query? On the documentation, it says that plans / memberships are post type, so I tried to query this table: SELECT jsu.id, jsu.user_email, jsu.display_name, jsp.post_title, jsp.post_type FROM `wp_users` jsu LEFT JOIN `wp_posts` jsp ON (jsu.id = jsp.post_author) LEFT JOIN `wp_usermeta` jsum ON (jsu.id =

Text under Add to cart (woocommerce)

房东的猫 提交于 2019-12-10 10:37:21
问题 How can I add a text saying "Contact us for bulk purchase enquiry" under 'Add to cart' button for all woocommerce products. Thanks 回答1: Try adding this code to your functions.php file : add_action( 'woocommerce_after_add_to_cart_button', 'content_after_addtocart_button_func' ); function content_after_addtocart_button_func() { // Echo content. echo '<div style="font-size:10px;"><em>(*Contact us for bulk purchase enquiry)</em></div>'; } Hope it helps! 来源: https://stackoverflow.com/questions

Display orders with a custom status for “all” in Woocommerce admin orders list

孤街醉人 提交于 2019-12-10 10:13:57
问题 I have created few custom order status using this code register_post_status( 'wc-arrival-shipment', array( 'label' => 'Shipped but not paid', 'public' => false, 'show_in_admin_status_list' => true, 'show_in_admin_all_list' => true, 'exclude_from_search' => false, 'label_count' => _n_noop( 'Shipped but not paid<span class="count">(%s)</span>', 'Shipped but not paid <span class="count">(%s)</span>' ) ) ); All is running good except of all orders listing. it shows the correct count all(3) but in

WooCommerce: Check if coupon is valid

被刻印的时光 ゝ 提交于 2019-12-10 09:34:14
问题 I am trying to check if a coupon is still valid (hasn't reached its usage limit) and display content under this condition. The reason for this is that I want to be able to hand out a coupon code to particular visitors, but obviously don't want to hand out a coupon that has already reached it's usage limit. I am trying to achieve this with PHP and imagine the code to be something like this: <?php if (coupon('mycouponcode') isvalid) { echo "Coupon Valid" } else { echo "Coupon Usage Limit

Get fields from checkout form into calculate_shipping

感情迁移 提交于 2019-12-10 03:59:38
问题 I'm creating a custom shipping calculator for my WooCommerce store. I need to collect some extra form data from the user to calculate the shipping properly. I have the form fields added to woocommerce_checkout_after_customer_details . I can probably get this into the cart page without much trouble once I figure out the checkout page functionality, so let's focus on this. I have a class extending WC_Shipping_Method with a calculate_shipping method a la this tutorial. In that method, I want to