Skip to content

Instantly share code, notes, and snippets.

Avatar

Clifton Griffin clifgriffin

View GitHub Profile
View maia.php
// Add to WP Admin > CheckoutWC > Advanced > Scripts > PHP Snippets
remove_action( 'woocommerce_checkout_after_order_review', 'woocommerce_checkout_payment', 20 );
@clifgriffin
clifgriffin / disable-order-bumps-at-checkout.php
Created Jul 14, 2022
Disable all order bumps at checkout (CheckoutWC)
View disable-order-bumps-at-checkout.php
<?php
add_filter(
'cfw_display_bump',
function() {
return ! is_checkout();
}
);
@clifgriffin
clifgriffin / thank-you-page-shortcode-example.php
Created Jul 13, 2022
Output a shortcode on the thank you page, wrapped in our section wrapper
View thank-you-page-shortcode-example.php
<?php
add_action( 'cfw_thank_you_cart_summary', 'my_thank_you_shortcode_wrapped', 65 );
function my_thank_you_shortcode_wrapped() {
cfw_thank_you_section_auto_wrap(
function() {
echo do_shortcode( '[your_shortcode]' );
},
'my-shortcode-section'
);
@clifgriffin
clifgriffin / rearrange-fields.php
Created Jun 23, 2022
Handling extra long state field label with CheckoutWC and WooCommerce
View rearrange-fields.php
<?php
/**
* Handling long state labels
*
* Example: German state field label exceeds state field container ("Bundesland / Landkreis (optional)")
*/
// Option 1: Rearrange address fields to make state field wider
add_filter(
'woocommerce_default_address_fields',
@clifgriffin
clifgriffin / example.php
Created Jun 18, 2022
Change 'No shipping methods available' text
View example.php
<?php
add_filter(
'cfw_shipping_total_not_available_text',
function () {
return 'My custom no shipping message.';
}
);
View disable-checkoutwc-side-cart-example.php
<?php
add_filter(
'cfw_disable_side_cart',
function() {
return boolval( preg_match( "/^\/the-page-slug/", $_SERVER['REQUEST_URI'] ) );
}
);
View custom-parsley-validator-field-example.php
<?php
// See:
add_filter( 'woocommerce_default_address_fields', function( $fields ) {
$fields['first_name']['custom_attributes']['data-parsley-multiple-of'] = '3';
return $fields;
}, 100000 + 100 );
View phone-field-label.php
<?php
add_filter(
'woocommerce_default_address_fields',
function( $fields ) {
$fields['phone']['label'] = 'Mobile Phone';
$fields['phone']['placeholder'] = 'Mobile Phone';
return $fields;
}, 100000 + 100
);
View change-thank-you-page-continue-shopping-button-url.php
<?php
// Add to WP Admin > CheckoutWC > Advanced > PHP Snippets
// Or to your child theme's functions.php file
// Do NOT include opening PHP tag above (<?php)
add_filter( 'woocommerce_continue_shopping_redirect', function() {
return 'https://thenewurl.test';
} );
View change-thank-you-continue-shopping-button-text.php
<?php
// Add to WP Admin > CheckoutWC > Advanced > PHP Snippets
// Or to your child theme's functions.php file
// Do NOT include opening PHP tag above (<?php)
add_filter( 'cfw_thank_you_continue_shopping_text', function() {
return 'Your Text!';
} );