Skip to content

Instantly share code, notes, and snippets.

View iMazed's full-sized avatar

Ines iMazed

View GitHub Profile
@iMazed
iMazed / change-return-url.php
Created May 18, 2021 12:22
Change 'return to shop' URL in WooCommerce
/**
* Changes the redirect URL for the Return To Shop button in the cart.
*
* @return string
*/
function wc_empty_cart_redirect_url() {
return 'http://mywebsite.com/sample-page/';
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
@iMazed
iMazed / brexit-tax
Created January 12, 2021 13:47
Brexit Tax Country Selector
add_filter( 'woocommerce_product_get_tax_class', 'big_apple_get_tax_class', 1, 2 );
function big_apple_get_tax_class( $tax_class, $product ) {
if ( WC()->cart->subtotal > 150 // 150 eur = 135 gbp, until a live rate is available
&& WC()->customer->get_billing_country() === 'GB' // only change the tax class for customers from GB. _billing_ can be changed to _shipping_ as well.
&& ! preg_match( 'BT', strtoupper( WC()->customer->get_billing_postcode() ) ) // but only those outside of Northern Ireland
) {
$tax_class = 'Zero Rate';
}
return $tax_class;
}
@iMazed
iMazed / gist:a6d1c938623ea772a4adbdce88d93c8a
Created November 30, 2020 05:44
Update Follow-Ups email on account update
add_action('profile_update', 'wc_fue_update_customers_table_user_profile_update', 10, 2);
function wc_fue_update_customers_table_user_profile_update( $user_id, $old_user_data ) {
// step 1 - get user from user id and email.
$user = get_userdata($user_id);
if ( !$user ) {
return;
}
@iMazed
iMazed / extend-subscription-intervals.php
Last active February 4, 2020 08:19 — forked from thenbrent/extend-subscription-intervals.php
Add a new billing interval to WooCommerce Subscriptions. Specifically a "every 25 weeks" billing interval to selling a subscription to something and be charged every 10 weeks.
<?php
/**
* Plugin Name: Extend WooCommerce Subscription Intervals
* Description: Add a "every 25" billing interval to WooCommerce Subscriptions
* Author: Brent Shepherd
* Author URI: http://brent.io
* Version: 1.0
* License: GPL v2
*/
@iMazed
iMazed / move-eu-vat-field.css
Created November 20, 2017 09:48
Move EU VAT Number field
#woocommerce_eu_vat_number {
position: absolute;
top: 230px;
width: 100%;
}
#billing_country_field {
margin-top: 6em;
}
@iMazed
iMazed / changehover.css
Last active June 8, 2017 09:25
Change hover button color
.woocommerce-message a.button.wc-forward:hover {
color: #222 !important; /* change this color code! */
}
.woocommerce input.button, .woocommerce input.button:hover {
color: #333 !important;
}
@iMazed
iMazed / ppc-cpt.php
Created January 29, 2017 17:26
Make Pre-Publish Post Checklist work with Custom Post Types
/**
* Make Pre-Publish Post Checklist work with Custom Post Types
* Add to your functions.php file
*/
function my_add_meta_boxes() {
add_meta_box(
'pc-meta-box',
'Pre-Publish Post Checklist',
'pc_create_meta_box_callback',
'YOUR_CPT', /* Change this your Custom Post Type ID */
@iMazed
iMazed / gist:82f5aa0a53524139ed1d8b64fced6994
Created October 1, 2016 13:17
Change WooCommerce stock email recipient
add_filter('woocommerce_email_recipient_backorder', 'wc_change_admin_backorder_email_recipient', 1, 2);
function wc_change_admin_backorder_email_recipient( $recipient, $order ) {
global $woocommerce;
$recipient = "shop-manager-email@yourdomain.com"; // change this value to the appropriate email!
return $recipient;
}
@iMazed
iMazed / suffix.php
Created July 26, 2016 10:41
Add suffix to WooCommerce product price
add_filter( 'woocommerce_get_price_html', 'custom_price_suffix', 100, 2 );
function custom_price_suffix( $price, $product ){
$price = $price . ' +VAT';
return apply_filters( 'woocommerce_get_price', $price );
}
@iMazed
iMazed / woo-surcharge.functions.php
Last active October 14, 2016 12:32
Add a surcharge to your WooCommerce cart/checkout
<?php
/**
* Add a 3% surcharge to your cart / checkout
* change the $percentage to set the surcharge to a value to suit
*/
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
global $woocommerce;
if ( is_admin() && ! defined( 'DOING_AJAX' ) )