hook-woocommerce

Add text before product price if it's higher than a specific amount in Woocommerce

跟風遠走 提交于 2019-12-06 05:37:35
In Woocommerce I'm trying to add text before price if is higher than 59€ I tried the following code (and others one) but they didn't work: add_filter( 'woocommerce_get_price_html', 'custom_price_message' ); function custom_price_message( $price ) { if ($price>='59'){ $new_price = $price .__('(GRATIS!)'); } return $new_price; } How can I do to add (GRATIS!) text before product price if it's higher than 59? Updated: You should try the following revisited function code: add_filter( 'woocommerce_get_price_html', 'prepend_text_to_product_price', 20, 2 ); function prepend_text_to_product_price(

Add coupon to the processing order email only if the customer have not used one

天涯浪子 提交于 2019-12-06 04:07:09
问题 I came across this snippet that adds a coupon to the order mail. I would like to make it appear in the processing order mail only if the customer have not used any coupon. add_action( 'woocommerce_email_before_order_table', 'add_content', 20 ); function add_content() { echo '<h2 id="h2thanks">Get 20% off</h2><p id="pthanks">Thank you for making this purchase! Come back and use the code "<strong>Back4More</strong>" to receive a 20% discount on your next purchase! Click here to continue

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

℡╲_俬逩灬. 提交于 2019-12-06 01:44:33
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 the listing you will only see 1 order and it is not displaying all 2 other orders which has been

How to create multiple simple-products with same SKU in WooCommerce?

做~自己de王妃 提交于 2019-12-06 01:08:50
问题 I want to create multiple simple-product with same SKU in WooCommerce. I search in admin settings but there I cannot find any settings to enable this features. Is there any hook so I can disable this features. 回答1: If you want to completely disable the SKU feature then you have to use wc_product_sku_enabled filter. It will remove the SKU field from both backend and frontend. add_filter( 'wc_product_sku_enabled', '__return_false' ); If you want to keep the SKU feature but need to disable

How to get Pay Now URL with custom order status in WooCommerce?

こ雲淡風輕ζ 提交于 2019-12-05 06:47:03
问题 I want to get the URL from where Customer can directly pay for their Invoice and also it should work with wc-cancelled and wc-transaction-declined ( custom order status ). My Solution What I'm doing now is created a custom page with my custom get parameters and processing the whole Payment Process as Documentation in Gateway provider Website. My Problem But the problem is whenever they update there doc file and plugin I also have to update my code; but if I get the Pay Now URL then

How to enable price and inventory for custom product type in WooCommerce

耗尽温柔 提交于 2019-12-05 02:06:26
问题 I created a custom product type in my WooCommerce application function register_variable_bulk_product_type() { class WC_Product_Variable_bulk extends WC_Product_Simple { public function __construct($product) { $this->product_type = 'variable_bulk'; parent::__construct($product); } } } add_action('init', 'register_variable_bulk_product_type'); function add_variable_bulk_product($types) { $types['variable_bulk'] = __('Variable Bulk'); return $types; } add_filter('product_type_selector', 'add

Add custom fee to recurring total woocommerce subscription

余生长醉 提交于 2019-12-04 21:31:54
function add_woocommerce_stripe_fee() { if ( ( is_admin() && ! defined( 'DOING_AJAX' ) ) || ! is_checkout() ) return; $chosen_gateway = WC()->session->chosen_payment_method; if ( 'stripe' == $chosen_gateway ) { $fee = (WC()->cart->cart_contents_total * .035) +0.35; WC()->cart->add_fee( 'Stripe Fee', $fee, false, '' ); } } add_action( 'woocommerce_cart_calculate_fees','add_woocommerce_stripe_fee' ); It is not adding for recurring cart total but works fine for normal product ( not working for Subscription products ). Any help would be greatly appreciated. Is this possible.? I provided a more in

Display the customer IP Address in new order email notification

£可爱£侵袭症+ 提交于 2019-12-04 18:29:04
When a new order is created, woocommerce will send an email to admin, and I want it to send customer's IP address inside the email as well. But I can't get it work, here is what I got so far: <?php echo get_post_meta( $order->id, '_customer_ip_address', true ); ?> This code goes in mytheme/woocommerce/emails/admin-new-order.php Any ideas? Thanks. (added compatibility for WooCommerce versions 3+) Update 2: Added a condition to display the address IP only for Admin New orders notification. Replaced undefined $email_id by $email->id; You can use any related hooks for the emails notifications and

Passing custom data from cart items to Order meta in Woocommerce 3

帅比萌擦擦* 提交于 2019-12-04 18:14:32
I have implemented a custom HTML Form and asking for some data which my customers will pass to place order successfully. Without these details my order has no importance. For HTML form, I am referencing some custom PHP script which is below and which processes POST data from the Form and creates Cart with these data programmatically. Thanks @LoicTheAztec to help me achieve this. The script.php file code: <?php require_once("../wp-load.php"); $customer_name = $_POST["customer_name"]; $customer_email = $_POST["customer_email"]; $customer_sex = $_POST["customer_sex"]; $customer_age = $_POST[

Adding Extra Add to cart button below product summary in Woocommerce

落爺英雄遲暮 提交于 2019-12-04 17:36:20
In WooCommerce, I am trying to add an extra add to cart button below product summary. I successfully added an extra button following this code which works for single products: add_action( 'woocommerce_single_product_summary', 'custom_button_after_product_summary', 30 ); function custom_button_after_product_summary() { global $product; echo "<a href='".$product->add_to_cart_url()."'>add to cart</a>"; } But if the product is a variation it doesn't work. please suggest as what to do? I have revisited your code a bit, and added a 2nd hooked function for variable products: // For Simple products