Skip to content

Instantly share code, notes, and snippets.

View clifgriffin's full-sized avatar

Clifton Griffin clifgriffin

View GitHub Profile
<?php
// See:
add_filter( 'woocommerce_default_address_fields', function( $fields ) {
$fields['first_name']['custom_attributes']['data-parsley-multiple-of'] = '3';
return $fields;
}, 100000 + 100 );
@clifgriffin
clifgriffin / phone-field-label.php
Created June 7, 2022 15:13
Change phone field label
<?php
add_filter(
'woocommerce_default_address_fields',
function( $fields ) {
$fields['phone']['label'] = 'Mobile Phone';
$fields['phone']['placeholder'] = 'Mobile Phone';
return $fields;
}, 100000 + 100
);
<?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';
} );
<?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!';
} );
@clifgriffin
clifgriffin / cart-item-thumbnail-filters.php
Created January 3, 2022 15:21
Modify CheckoutWC cart item thumbnail image settings.
<?php
// Add to your child theme's functions.php file or to WP Admin > CheckoutWC > Advanced > PHP Snippets
// Do NOT include opening PHP tag above (<?php)
// Cart item thumbnail width
// Default: 60
add_filter(
'cfw_cart_thumb_width',
function( $width ) {
@clifgriffin
clifgriffin / add-attribute-to-form-tag.php
Created January 3, 2022 14:36
Add custom attribute to checkout page form tag with CheckoutWC
<?php
// Add to funcions.php or to WP Admin > CheckoutWC > Advanced > PHP Snippets
// Do NOT include opening PHP tag above (<?php)
add_filter(
'cfw_form_attributes',
function( $attributes, $id ) {
// Only add our attribute on the checkout page,
// not the order pay page. Order Pay form ID is order_review
<?php
// Add to CheckoutWC > Advanced > PHP Snippets or to your child theme's functions.php file
// Do NOT include opening PHP tag above (<?php)
add_filter(
'cfw_additional_side_cart_trigger_selectors',
function() {
return '.some-parent-container .some-child-element, #another_parent_container #another_child_element';
}
);
--cfw-heading-font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
--cfw-body-font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
--cfw-body-background-color: #fff;
--cfw-body-text-color: #666;
--cfw-body-link-color: #0073aa;
--cfw-header-background-color: #fff;
--cfw-header-text-color: #2b2b2b;
--cfw-header-bottom-margin: 0;
--cfw-footer-background-color: #fff;
--cfw-footer-text-color: #999;
<?php
// Add to functions.php or to CheckoutWC > Advanced > PHP Snippets
// You can also use the Code Snippets plugin
// Do NOT include opening PHP tag above (<?php)
/**
* Set a minimum order amount for checkout
*/
add_action( 'woocommerce_checkout_process', 'wc_prevent_orders_under_minimum' );
add_action( 'woocommerce_before_cart', 'wc_cart_minimum_order_amount' );
@clifgriffin
clifgriffin / alert-example.php
Created June 1, 2021 14:10
Adding an alert to CheckoutWC.
<?php
// Add to functions.php or to CheckoutWC > Advanced > PHP Snippets
// Do NOT include opening PHP tag above (<?php)
/**
* Suggested locations
* - cfw_checkout_main_container_start: Above the breadcrumbs on every step
* - cfw_checkout_before_shipping_methods: Above the shipping methods list
* - cfw_checkout_payment_method_tab (Priority 9): Above the payment methods
*/