Skip to content

Instantly share code, notes, and snippets.

@LaurenaRehbein
LaurenaRehbein / stripe-icon-removal.php
Last active May 17, 2021 06:07
Removes chosen Stripe Icons from the gateway
// Remove icons from Stripe gateway
function lar_remove_icons( $icons ) {
$icons = str_replace( '<img src="' . WC_HTTPS::force_https_url(WP_PLUGIN_URL . '/woocommerce-gateway-stripe/assets/images/jcb.svg' ) . '" class="stripe-jcb-icon stripe-icon" alt="JCB" />', '', $icons );
$icons = str_replace( '<img src="' . WC_HTTPS::force_https_url(WP_PLUGIN_URL . '/woocommerce-gateway-stripe/assets/images/discover.svg' ) . '" class="stripe-discover-icon stripe-icon" alt="Discover" />', '', $icons );
$icons = str_replace( '<img src="' . WC_HTTPS::force_https_url(WP_PLUGIN_URL . '/woocommerce-gateway-stripe/assets/images/diners.svg' ) . '" class="stripe-diners-icon stripe-icon" alt="Diners" />', '', $icons );
return $icons;
}
add_filter( 'woocommerce_gateway_icon', 'lar_remove_icons');
@LaurenaRehbein
LaurenaRehbein / continue-shopping-redirect.php
Created February 28, 2019 20:08
Use this filter if you want customers to be redirected to a specific URL when they click "Continue Shopping"
<?php
// 'Continue Shopping' button re-direct
add_filter('woocommerce_continue_shopping_redirect', 'lar_wc_continue_shopping_redirect');
function lar_wc_continue_shopping_redirect( $redirect ) {
$redirect = 'http://yoururl.com/';
return $redirect;
}
@LaurenaRehbein
LaurenaRehbein / remove-payment-request-product-page.php
Created February 28, 2019 20:13
Use this to remove the Google Pay and Apple Pay buttons from the Single Product Pages, when using Stripe
<?php
add_filter( 'wc_stripe_hide_payment_request_on_product_page', 'lar_wc_stripe_hide_payment_request_on_product_page' );
function lar_wc_stripe_hide_payment_request_on_product_page() {
return true;
}
@LaurenaRehbein
LaurenaRehbein / bookings_form_order.php
Created March 19, 2019 17:14
This filter puts resources at the top of the bookings form, with WooCommerce Bookings.
<?php
function custom_order_booking_fields ( $fields ) {
$fields = array('wc_bookings_field_resource' => $fields['wc_bookings_field_resource']) + $fields;
return $fields;
}
add_filter( 'booking_form_fields', 'custom_order_booking_fields');
@LaurenaRehbein
LaurenaRehbein / backorder-text.php
Created March 27, 2019 20:43
Changes the text for backorder products
add_filter( 'woocommerce_get_availability_text', 'lar_custom_change_availability_text', 15, 2 );
function lar_custom_change_availability_text( $availability, $product ) {
if ( $product->backorders_require_notification() ) {
$availability = __( 'Custom text here', 'woocommerce' );
}
return $availability;
}
@LaurenaRehbein
LaurenaRehbein / get-text.php
Created April 11, 2019 18:14
A filter to change text using gettext filter. This one changes the WooCommerce/Storefront mini cart.
<?php
/**
* Change the “No products in the cart” message when hovering over the mini-cart
*
*/
function lar_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case ‘No products in the cart.’ :