Skip to content

Instantly share code, notes, and snippets.

Avatar

Clifton Griffin clifgriffin

View GitHub Profile
@clifgriffin
clifgriffin / validate-house-number.php
Created Feb 8, 2021
Validate that WooCommerce street address contains house number on CheckoutWC checkout page
View validate-house-number.php
<?php
// Add to functions.php or using the Code Snippets plugin
// Do NOT include opening PHP tag above (<?php)
add_filter(
'woocommerce_default_address_fields',
function( $fields ) {
unset( $fields['postcode']['custom_attributes']['data-parsley-length'] );
@clifgriffin
clifgriffin / hide-cart-breadcrumb.css
Created Jan 28, 2021
Hide CheckoutWC cart breadcrumb.
View hide-cart-breadcrumb.css
/** Add to Settings > CheckoutWC > Design > Custom CSS **/
#​cfw-breadcrumb .cart {
​display: none;
​}
View validate-house-number.php
<?php
add_filter( 'woocommerce_default_address_fields', function( $fields ) {
$fields['address_1']['custom_attributes']['data-parsley-pattern'] = '.*[0-9].*';
$fields['address_1']['custom_attributes']['data-parsley-error-message'] = 'Please enter your house number.';
return $fields;
}, 100001 );
@clifgriffin
clifgriffin / cart-item-quantity-step.php
Created Dec 2, 2020
Add minimum quantity and quantity step to quantity control for CheckoutWC (Checkout for WooCommerce)
View cart-item-quantity-step.php
<?php
// Add to functions.php or using Code Snippets
// Do NOT include opening PHP tag above (<?php)
add_filter( 'cfw_cart_item_quantity_min_value', function( $min_value, $cart_item, $cart_item_key ) {
$min_value = 6;
return $min_value;
}, 10, 3 );
@clifgriffin
clifgriffin / add-additional-tab.php
Last active Jan 13, 2021
Add additional tab to CheckoutWC checkout flow for WooCommerce.
View add-additional-tab.php
<?php
// Add to functions.php or with your favorite Code Snippets plugin
// Do not include opening PHP tag (<?php)
/**
* Add Breadcrumb
*/
add_filter( 'cfw_breadcrumbs', function( $breadcrumbs ) {
$breadcrumbs['age_verification'] = array(
'href' => '#age_verification', // must match tab ID
View change-promo-code-labels.php
<?php
// Do NOT include opening PHP tag above (<?php)
// Add to:
// - functions.php in child theme
// - Code Snippets
// - Settings > CheckoutWC > Premium Features > PHP Snippets (for Growth and Developer plans)
add_filter( 'cfw_promo_code_mobile_heading', function() {
return __( 'Coupon code', 'checkout-wc' );
@clifgriffin
clifgriffin / add-email-field-for-loggedin-users.php
Last active Sep 5, 2020
Add email field back for logged in users for CheckoutWC (Checkout for WooCommerce)
View add-email-field-for-loggedin-users.php
<?php
// Do NOT include opening PHP tag above (<?php)
// Add to:
// - functions.php in child theme
// - Code Snippets
// - Settings > CheckoutWC > Premium Features > PHP Snippets (for Growth and Developer plans)
add_action( 'cfw_after_customer_info_tab_login', function() {
if ( ! is_user_logged_in() ) {
@clifgriffin
clifgriffin / show-shipping-method-in-totals.php
Last active Aug 21, 2020
Show shipping method in CheckoutWC totals table.
View show-shipping-method-in-totals.php
<?php
// Do NOT include opening PHP tag above (<?php)
add_filter( 'cfw_cart_totals_shipping_label', function( $label ) {
$chosen_shipping_methods_labels = array();
$packages = WC()->shipping->get_packages();
foreach ( $packages as $i => $package ) {
$chosen_method = WC()->session->get( 'chosen_shipping_methods' )[ $i ] ?? false;
@clifgriffin
clifgriffin / rey-theme-fixes.php
Created Jul 28, 2020
Rey Theme fixes for CheckoutWC (Checkout for WooCommerce)
View rey-theme-fixes.php
<?php
// Do NOT include opening PHP tag above (<?php)
remove_action( 'woocommerce_before_checkout_form', 'reycore_wc__cart_progress', 5 );
@clifgriffin
clifgriffin / always-show-cart-on-mobile.css
Created May 26, 2020
Always show cart summary expanded on mobile when on the payment tab with Checkout for WooCommerce
View always-show-cart-on-mobile.css
.cfw-payment-method-active #cfw-cart-summary-content {
display: block !important;
padding-top: 1em; /* make sure the quantity bubbles on cart items don't leave the containers */
}
.cfw-payment-method-active #cfw-mobile-cart-header {
display: none !important;
}