Orange County, CA

(949) 876 - 5309 swanlegacy@gmail.com

Category: Business Bloomer

WooCommerce: Display $0.00 Amount For Free Shipping Rates

In the past, WooCommerce cart and checkout pages used to show “$0.00” beside each free shipping rate. But given that many freelance clients requested this customization, today we’re bringing this back to life with just a few lines of PHP
WooCommerce: display 0 amount beside free shipping rates at cart & checkout PHP Snippet: Display $0.00 Amount For Free Shipping Rates @ WooCommerce Cart & Checkout /** * @snippet Display $0.00 Amount For Free Shipping Rates @ WooCommerce Cart & Checkout * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72869 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.2 */ add_filter( 'woocommerce_cart_shipping_method_full_label', 'bbloomer_add_0_to_shipping_label', 10, 2 ); function bbloomer_add_0_to_shipping_label( $label, $method ) { // if shipping rate is 0, concatenate “: $0.00” to the label if ( ! ( $method->cost > 0 ) ) { $label .= ': ' . wc_price(0); } // retu..

Read More

WooCommerce: Calculate Sales by State

You’re filling out your tax reports… and then find out WooCommerce doesn’t give you this calculation by default!
Don’t cry Today I’ll show you a quick snippet to calculate that in a second. Feel free to change the year, the country and the states in the snippet.
WooCommerce: get sales by state PHP Snippet: Get Sales by State @ WooCommerce Admin (Reports) /** * @snippet Get Sales by State @ WooCommerce Admin * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72853 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.2 */ // ———————– // 1. Create extra tab under Reports / Orders add_filter( 'woocommerce_admin_reports', 'bbloomer_admin_add_report_orders_tab' ); function bbloomer_admin_add_report_orders_tab( $reports ) { $array = array( 'sales_by_state' => array( 'title' => 'Sales by state', 'description' => '', 'hide_title' => 1, &#0..

Read More

WooCommerce: Display Categories Under Product Name @ Cart

While working for a freelance client I had to “detect” the cart item categories in order to apply some PHP customization. So I thought – why not sharing with you how to display product categories in the Cart? This adds a nice touch to the Cart page
Also, I’m glad to introduce you to the amazing world of “wc_get_product_category_list“, a very handy WooCommerce PHP function!
Display product categories under each item in the WooCommerce Cart PHP Snippet: Display Categories Under Product Name @ WooCommerce Cart /** * @snippet Display Categories Under Product Name @ WooCommerce Cart * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72844 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.2 */ add_filter( 'woocommerce_cart_item_name', 'bbloomer_cart_item_category', 99, 3); function bbloomer_cart_item_category( $name, $cart_item, $cart_item_key ) { $product_item = $cart_item['data']; $cat_ids = $p..

Read More

WooCommerce: Display Product-Specific T&C @ Checkout

A freelance client sells two distinct products on the same website: a membership and an online course. Two different audiences, different formats and… different Terms & Conditions.
The goal was therefore to display the “Terms & Conditions” checkbox on the Checkout page based on the product in the cart. Once again, we’re going to use Conditional Logic. With that, the snippet is pretty easy to code!
WooCommerce: Conditional Terms & Conditions @ Checkout PHP Snippet: Terms & Conditions by Product – WooCommerce Checkout /** * @snippet Terms & Conditions by Product – WooCommerce Checkout * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72828 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.1 */ add_action('woocommerce_review_order_before_submit', 'bbloomer_add_checkout_tickbox', 9); function bbloomer_add_checkout_tickbox() { // Show Terms 1 $product_id_1 = 522; $product_cart_id_1 = WC()->cart->generate_..

Read More

WooCommerce: Detecting Current User Country (Geolocation)

In the redesign of Business Bloomer homepage, launched recently, I wanted to add some “personalization” to the main headline. In detail, I wanted to make use of PHP and WooCommerce inbuilt MaxMind Geolocation (when enabled from the General Settings Tab of course) to print a custom greeting on the screen.
The detection of the current user country could be very useful for other tasks, such as disabling payment gateways and shipping methods, printing country-specific content and so on. And as usual, this “detection” is done with one line of code!
The new Business Bloomer homepage with a “personalized” greeting based on Geolocated User Country PHP Snippet: Get Current User Country (Geolocation) – WooCommerce /** * @snippet Get Current User Country (Geolocation) – WooCommerce * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72811 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.2 */ function bbloomer_use_geolocated_user_co..

Read More

WooCommerce: Order a “Free Sample” @ Single Product Page

Recently I was on a coaching call with a client and the “Free Sample” challenge came up. Client has 400+ products on the website and had no intention of adding a free variation to each product manually.
So, I promised to myself I was going to study a different approach. And today you get it completely free. Needless to say, a comment and a social media share are much appreciated
Display an “Add Free Sample to Cart” button @ WooCommerce single product page Requirements for “Free Sample” – WooCommerce Before digging into the PHP, you will need to create a brand new simple product called exactly “Free Sample”.
Here are the requirements:
Title: “Free Sample” Price: $0 Catalog Visibility: “Hidden” Inventory: “Sold Individually” Make sure to remember the product ID, which will be necessary in the PHP
PHP Snippet: “Free Sample” Add to Cart Button @ Single Product Page – WooCommerce /** * @snippet “Free Sample” @ Single Product Page – WooCommerce * @how-to Watch tutorial @ https://busin..

Read More

WooCommerce: “Continue Shopping” Button @ Single Product Page

A freelance client hired me a while ago to display a “Continue Shopping” button on the Single Product Page, next to the Add to Cart. A simple way to send their users back to where they were coming from without clicking the “previous” button on the browser
Here’s how it’s done, featuring an awesome WordPress function called “wp_get_referer()”!
Continue Shopping button @ WooCommerce Single Product Page PHP Snippet: “Continue Shopping” Button @ Single Product Page – WooCommerce /** * @snippet Continue Shopping button @ Single Product Page * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72772 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.1 */ add_action( 'woocommerce_single_product_summary', 'bbloomer_continue_shopping_button', 31 ); function bbloomer_continue_shopping_button() { if ( wp_get_referer() ) echo 'Continue Shoppi..

Read More

WooCommerce: Change Add to Cart “Quantity” into a Drop-down

The default WooCommerce Add to Cart “Quantity Input” is a simple input field where you can enter the number of items or click on the “+” and “-” to increase/reduce the quantity.
A freelance client hired me to turn that input into a “Select” drop-down. For their audience and UX requirements, it makes sense to let their customers choose the quantity from a drop-down instead of having to manually input the number.
Online there are complex snippets, but I decided to make things easier. The WooCommerce function responsible to generate the quantity input is called “woocommerce_quantity_input“. Luckily, it’s a pluggable function – which means we can simply add this exact same function name to our child theme’s functions.php to completely override it.
WooCommerce: turn Add to Cart Quantity input into a select drop-down PHP Snippet: Turn Add to Cart “Quantity” into a select drop-down – WooCommerce /** * @snippet Add to Cart Quantity drop-down – WooCommerce * @how-to Watch tutorial @ https://..

Read More

WooCommerce: Easily Check if Product ID is in the Cart

This is one of those “OMG” moments
Here’s the story: I’m working with one of my freelance clients and I need to show certain content in the checkout (a product-specific “Terms and Conditions”) if such product is in the Cart.
I’ve always looked for products in the Cart by “looping” through the Cart with a foreach (here, for example: Apply a Coupon Programmatically if a Product is in the Cart).
But as I said, after some random research, I found out about another magic WooCommerce function: “find_product_in_cart()”. Which means finding a product in the Cart doesn’t need to do custom loops or complex PHP… it’s a “one liner”!
WooCommerce: find if product ID is in the Cart PHP Snippet: Easily Check if Product ID is in the Cart – WooCommerce /** * @snippet Check if Product ID is in the Cart – WooCommerce * @how-to Watch tutorial @ https://businessbloomer.com/?p=19055 * @sourcecode https://businessbloomer.com/?p=72733 * @author Rodolfo Melogli * @testedwith WooCommerce 3.1.1 */ add_actio..

Read More

WooCommerce: Easily Get Product Info (title, SKU, desc) from $product Object

I’ve been wanting to publish this guide for a long while. As a freelancer, every day I repeat many operations that make me waste time – and one of them is indeed “How to get ____ if I have the $product variable/object?”.
For example, “How can I get the product SKU”? Or “How can I get the product short description”? Or maybe the product stock level, shipping class, tax class, price, regular price, sale price, and so on… hopefully this article will save you time
1. You have access to $product Hooks (do_action and apply_filters) use additional arguments which are passed on to the function. If they allow you to use the “$product” object you’re in business. Alternatively, you can declare the “global $product” inside your function.
In both cases, here’s how to get all the product information:
// Get Product info if $product is available to you $product->get_type(); $product->get_name(); $product->get_slug(); $product->get_date_created(); $product->get_date_modified(); $product->get_sta..

Read More
Facebook Auto Publish Powered By : XYZScripts.com