I’m totally new to WordPress and WooCommerce, so apologies for the poor explanation. I have this code: And need to display $vars->ID in my function: So I got: How can I access $vars variable value in my callback function? Answer As you can see apply_filters( ‘prefix_xml_feeds_productname_variant’, $text, $product_item->ID, $vars->ID ); contains 3 parameters So you could use it like More
Tag: hook-woocommerce
WooCommerce Order Export: Get custom data per line item
I’m using the “WooCommerce Customer / Order / Coupon Export” plugin to export my orders as a CSV file. I’m exporting the orders in a one row per item format. This means that every order has multiple lines. One line per order item. Now I want to add some extra data to every line item. For example the author (in
Dynamic custom order numbers based on payment method
I have the following code in my functions.php file: The code works but I want it to permanently save the new order number. It should permanently make CHEXXXX (ex. CHE5783) the order number in the database if the user checked out using check payments. Right now this code only makes it temporary. It does not need to update previous order
How can I remove parentheses from WooCommerce subcategory product count
On any default WooCommerce category page, it lists categories (product photo, title/link) with a number in parenthesis. For example, Finishing (6). The page html looks like this: I tried this php to remove just the parenthesis, obviously that didn’t work: My goal is to style that count with a background color and border radius, which I can’t now because the
Display “In Stock” notice for WooCommerce variations with no Managed Stock
I need help for a particular situation. In WooCommerce, if “Manage Stock” is enabled for a simple product or variation, then a notification is being displayed in the product page => such as [this example][1] However, if “Manage Stock” is not enabled, then there is no notification which I find it a pity because I still want to inform my
Woocommerce minimum order total based on user roles
I’m using a snippet code from Woocommerce Minimum Order Amount to set a minimum order total. But I would like to set different minimums per user role. I have some custom user roles: wholesale_prices, wholesale_vat_exc, and distributor_prices. I want to make the code to work based on use roles with different minimum amounts for each role. Here is my code:
Set a custom shipping cost on every 10th Order in WooCommerce
WP 5.3.3 I need to change shipping cost programmatically, after order creation. This code doesn’t affect: add_action(‘woocommerce_new_order’, ‘custom_shipping_costs’, 1, 1); function …
Switch product image on hover on WooCommerce archive page
Is there a way (maybe via functions.php) to change the product-image in woocommerce shops (archive page) on hover with the first attached gallery image of the product? I cannot find how to target both. I guess it must be sth like this: Answer What I think you’ll want to do, assuming your installation is a somewhat standard WooC installation, is
Add 50% discount per 3 products on the cheapest products (WooCommerce)
I’m adding the discount rule for every 3 products: 3,6,9,12,15.. on the cart and it should apply to discount 50% only the cheapest products. So if you have 9, only the 3 cheapest gets 50% off. This …
Check WooCommerce User Role and Payment Gateway and if they match – Apply fee
I’m struggling with applying a fee for an array of user roles if and when a specific payment gateway is selected. The code I’ve written works fine if I do not check the user role, but once I try and …