Skip to content

Instantly share code, notes, and snippets.

@media only screen and (max-width: 768px) {
.homepage-banner {
display: block;
}
}
@LaurenaRehbein
LaurenaRehbein / validate-settings.php
Created October 17, 2016 22:53
Validate your WooCommerce integration settings.
public function validate_api_key_field( $key, $value ) {
if ( isset( $value ) && 20 < strlen( $value ) ) {
WC_Admin_Settings::add_error( esc_html__( 'Looks like you made a mistake with the API Key field. Make sure it isn&apos;t longer than 20 characters', 'woocommerce-integration-demo' ) );
}
return $value;
}
@LaurenaRehbein
LaurenaRehbein / pipsupport
Created October 27, 2016 23:56
Add PIP support to Shipping Multiple Addresses
add_action( 'wc_pip_after_body', 'add_shipping_addresses_to_pip', 10, 4 );
function add_shipping_addresses_to_pip( $type, $action, $document, $order ) {
global $wcms;
if ( 'invoice' == $type ) {
$wcms->order->display_order_shipping_addresses($order);
}
}
@LaurenaRehbein
LaurenaRehbein / remove_price.php
Last active January 12, 2018 19:38
To remove the Subscription Price
function wtd_remove_var_subscriptions_price() {
return '';
}
add_filter( 'woocommerce_variable_subscription_price_html', 'wtd_remove_var_subscriptions_price' );
@LaurenaRehbein
LaurenaRehbein / custom_price_string.php
Created May 18, 2017 00:41
To change the wording on the Donations customization
function wtd_subscriptions_custom_price_string( $pricestring ) {
$newprice = str_replace( 'for 1 day', 'once', $pricestring );
return $newprice;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'wtd_subscriptions_custom_price_string' );
function lr_subscriptions_custom_price_string( $pricestring ) {
$newprice = str_replace( 'every day once', 'once', $pricestring );
return $newprice;
}
@LaurenaRehbein
LaurenaRehbein / redirect_to_shop.php
Last active March 19, 2019 17:12
To redirect to a specific page other than "shop".
/**
* // Custom redirect for users after clicking 'return to shop'
**/
add_filter('woocommerce_return_to_shop_redirect', 'lr_wc_return_to_shop_redirect');
function lr_wc_return_to_shop_redirect( $redirect ) {
$redirect = '/products/donation/';
return $redirect;
}
@LaurenaRehbein
LaurenaRehbein / stripe-icon-filter.php
Created January 11, 2018 23:40
To change the Stripe 4.0 icons back to colour.
add_filter( 'wc_stripe_payment_icons', 'change_my_icons' );
function change_my_icons( $icons ) {
// var_dump( $icons ); to show all possible icons to change.
$icons['visa'] = '<img src="https://mysite.com/wp-content/plugins/woocommerce/assets/images/icons/credit-cards/visa.svg" />';
return $icons;
}
@LaurenaRehbein
LaurenaRehbein / stripe-icon-edit.php
Created January 12, 2018 00:12
A sample of the edited function
add_filter( 'wc_stripe_payment_icons', 'change_my_icons' );
function change_my_icons( $icons ) {
// var_dump( $icons ); to show all possible icons to change.
$icons['visa'] = '<img src="http://woocommerce-ext.reh/wp-content/plugins/woocommerce/assets/images/icons/credit-cards/visa.svg" />';
$icons['mastercard'] = '<img src="http://woocommerce-ext.reh/wp-content/plugins/woocommerce/assets/images/icons/credit-cards/mastercard.svg" />';
$icons['amex'] = '<img src="http://woocommerce-ext.reh/wp-content/plugins/woocommerce/assets/images/icons/credit-cards/amex.svg" />';
return $icons;
}
@LaurenaRehbein
LaurenaRehbein / customthankyou.php
Created May 8, 2018 19:51
Custom thank you page redirect
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( 'http://www.yoururl.com/your-page/' );
exit;
}
}
/**
* Function to remove the variable subscription price string
* Add this to your child theme's functions.php file.
*/
function wc_remove_var_subscriptions_price() {
return '';
}
add_filter( 'woocommerce_variable_subscription_price_html', 'wc_remove_var_subscriptions_price' );