Skip to content

Instantly share code, notes, and snippets.

@jrick1229
jrick1229 / wc_remove_shipping_billing_state.php
Created Apr 15, 2021
Remove the state field from both shipping and billing details section
View wc_remove_shipping_billing_state.php
<?php
add_filter( 'woocommerce_billing_fields', 'wc_remove_shipping_billing_state' );
add_filter( 'woocommerce_shipping_fields', 'wc_remove_shipping_billing_state' );
function wc_remove_shipping_billing_state( $fields ) {
unset( $fields[ 'billing_state' ] );
unset( $fields[ 'shipping_state' ] );
return $fields;
}
@jrick1229
jrick1229 / wc_backordered_notice.php
Created Apr 3, 2021
Display a notice on the product and cart page when a product is backordered.
View wc_backordered_notice.php
<?php
add_filter('woocommerce_product_backorders_require_notification', '__return_true', 1);
@jrick1229
jrick1229 / PAO_remove_percentage.php
Created Mar 31, 2021
Remove % from Product Add-Ons percentage based add-on
View PAO_remove_percentage.php
<?php
add_filter( 'woocommerce_product_addons_option_price', 'PAO_remove_percentage', 1);
function PAO_remove_percentage() {
$price_raw = '( . $price_prefix . $price_raw )';
}
@jrick1229
jrick1229 / wc_price_add_USD.php
Created Feb 25, 2021
Append USD to price string in WooCommerce
View wc_price_add_USD.php
<?php
add_filter( 'wc_price', 'wc_price_add_USD', 10, 3 );
function wc_price_add_USD( $return, $price, $args){
$price= "$" . $price . " USD";
return $price;
}
View wc_disable_persistent_cart.php
<?php
add_filter('woocommerce_persistent_cart_enabled', function () {
return false;
});
@jrick1229
jrick1229 / custom_after_add_to_cart_btn.php
Last active Jan 19, 2021
Add custom add to cart text (below add to cart button) on certain product IDs.
View custom_after_add_to_cart_btn.php
<?php
add_action( 'woocommerce_after_add_to_cart_button', 'custom_after_add_to_cart_btn' );
function custom_after_add_to_cart_btn(){
global $product;
$id = $product->get_id();
$product_ids = array( 501, 176 );
@jrick1229
jrick1229 / bbloomer_shipping_phone_checkout.php
Last active Dec 18, 2020
Altered BusinessBloomer snippet to make phone field required for shipping address, as well as moving it to make it conform to billing address location
View bbloomer_shipping_phone_checkout.php
<?php
/**
* @snippet Shipping Phone & Email - WooCommerce
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 3.6.4
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
@jrick1229
jrick1229 / wcs_gifting_autocheck.php
Created Dec 8, 2020
Auto-check the Subscriptions Gifting checkbox on the product page
View wcs_gifting_autocheck.php
<?php
add_filter('wcsg_recipient_checkbox_checked', '__return_true');
@jrick1229
jrick1229 / wcsg_shipping_address_false.php
Created Nov 27, 2020
Do not require a WooCommerce Subscriptions Gifting recipient to enter a shipping address when completing their account creation
View wcsg_shipping_address_false.php
<?php
add_filter( 'wcsg_require_shipping_address_for_virtual_products', '__return_false' );
@jrick1229
jrick1229 / woocommerce_subscriptions_processing_order_override.php
Created Nov 25, 2020
Set all orders to Processing on payment complete - even ones containing products marked as Virtual & Downloadable
View woocommerce_subscriptions_processing_order_override.php
<?php
/*
* set all orders to Processing on payment complete
* even ones containing products marked as Virtual & Downloadable
*/
add_action( 'woocommerce_payment_complete', 'woocommerce_subscriptions_processing_order_override' );
function woocommerce_subscriptions_processing_order_override( $order_id ) {
if ( ! $order_id ) {