WooCommerce

Elementor Cart Page Template

To make a cart page using the Elementor Template, follow these steps: Login to Cren Chicagos WordPress site. On the left side under Elementor, click templates and then Theme builder. Find the cart template and hover over it and click "Export Template". A file will download to your computer. On the site you want to […]

Sync/Make Infusionsoft and WooCommerce Order Numbers

add_filter('woocommerce_order_number', 'ov_iw_woocommerce_order_number',10,2); function ov_iw_woocommerce_order_number($last_id, $wcorder) { $wcid = $wcorder->id; $infusion_order_id = get_post_meta( $wcid, 'infusionsoft_order_id', true ); if($infusion_order_id) return $infusion_order_id; else return $last_id; }

Auto Complete WooCommerce Orders

/** * Auto Complete all WooCommerce orders. */ add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); function custom_woocommerce_auto_complete_order( $order_id ) { if ( ! $order_id ) { return; } $order = wc_get_order( $order_id ); $order->update_status( 'completed' ); }

WooCommerce Set Phone Number to Optional at Checkout

add_filter( 'woocommerce_billing_fields', 'wps_remove_filter_phone', 10, 1 ); function wps_remove_filter_phone( $address_fields ) { $address_fields['billing_phone']['required'] = false; return $address_fields; }

Override Price in WooCommerce for iMember360 Users

function return_custom_price($price, $product) { IF (i4w_has_tag('1330')) : { global $post, $blog_id; $price = get_post_meta($post->ID, '_regular_price'); $post_id = $post->ID; $price = i4w_get_contact_field('_HalfofShowCost'); return $price; } ELSEIF (i4w_has_tag('1328')) : { global $post, $blog_id; $price = get_post_meta($post->ID, '_regular_price'); $post_id = $post->ID; $price = i4w_get_contact_field('_HalfofShowCost'); return $price; } ELSEIF (i4w_has_tag('1332')) : { global $post, $blog_id; $price = get_post_meta($post->ID, '_regular_price'); […]

Clear Cart Through URL

// check for clear-cart get param to clear the cart, append ?clear-cart to any site url to trigger this add_action( 'init', 'woocommerce_clear_cart_url' ); function woocommerce_clear_cart_url() { if ( isset( $_GET['clear-cart'] ) ) { global $woocommerce; $woocommerce->cart->empty_cart(); } }

Automated Coupon Codes in WooCommerce plus Coupon Validation

Sometimes we need to implement coupons that automatically apply themselves based on what's in the cart, frequently as part of some sort of discount. Below is a snippet of commented code that I used to automatically apply a coupon based on two factors: A quantity of a specific product is in the cart The current […]

Smooth Scroll to Anchor Points when the Navbar covers the Anchor Point

Sometimes the scrolling to anchors is screwed up due to the sticky nav covering the content of the page. To fix this issue, we can apply some math to the 'scrollTop' value of an element. Here's the script that does just that:   <script> //Adds this to the onload event listener window.addEventListener('load', function(){ //Gets all […]