Skip to content

Instantly share code, notes, and snippets.

@bryceadams
bryceadams / gist:925a183619376feb5dcf5de9a84bcdd8
Created Jul 21, 2018
Metorik - Move add cart popup placement.
View gist:925a183619376feb5dcf5de9a84bcdd8
add_filter('metorik_acp_placement', function() {
return 'left';
});
@bryceadams
bryceadams / gist:4bcfce7f1ff341f9b1ad8cc98b3417bb
Last active Jul 20, 2018
Metorik - Stop cart checkout button 'popup' appearing.
View gist:4bcfce7f1ff341f9b1ad8cc98b3417bb
add_filter('metorik_acp_checkout_button', '__return_false');
@bryceadams
bryceadams / add-cart-email-form.php
Created Jul 5, 2018
Metorik Helper 1.0.0 - Add Cart Email Form template file
View add-cart-email-form.php
<?php
/**
* Metorik: Add cart email form template.
*
* This template can be overriden by copying this file to your-theme/metorik/add-cart-email-form.php
*
* Variables available:
* 1. $title - Title (set in Metorik).
* 2. $email_usage_notice - Email usage notice (if enabled in Metorik and customer didn't opt-out).
*
View wc-custom-meta-get.php
<?php
$order_id = 125;
echo get_post_meta( $order_id, 'payment_gateway_fee', true ); // 1.60
View wc-custom-meta-add.php
<?php
$order_id = 125;
add_post_meta( $order_id, 'payment_gateway_fee', 1.60 );
@bryceadams
bryceadams / gist:050d886159265d6f5e6dbce649552704
Last active Feb 1, 2021
Disable WooCommerce total spent / order count meta calculations
View gist:050d886159265d6f5e6dbce649552704
<?php
add_filter( 'get_user_metadata', 'mtkdocs_filter_user_metadata', 10, 4 );
function mtkdocs_filter_user_metadata( $value, $object_id, $meta_key, $single ) {
// Check if it's one of the keys we want to filter
if ( in_array( $meta_key, array( '_money_spent', '_order_count' ) ) ) {
// Return 0 so WC doesn't try calculate it
return 0;
}
// Default
@bryceadams
bryceadams / change.php
Created Jun 24, 2017
Automatically change 'pending cancel' subscriptions to 'cancelled'
View change.php
<?php
/**
* Move pending cancellation to cancelled automatically.
*/
function metorik_custom_cancel_function( $subscription, $new_status, $old_status ) {
if ( 'pending-cancel' === $new_status ) {
$subscription->update_status( 'cancelled' );
}
View gist:a7cbb78fef50f00f7d529d316d8093b3
<?php
// Remove that PHP above if you are having errors come up after saving the file.
/**
* Hide shipping rates when free shipping is available.
* Updated to support WooCommerce 2.6 Shipping Zones.
*
* @param array $rates Array of rates found for the package.
* @return array
*/
@bryceadams
bryceadams / metorik_stop_multiple_coupons.php
Last active Dec 15, 2020
Plugin to only allow individual use coupons in WooCommerce, even if they have not been set as such.
View metorik_stop_multiple_coupons.php
<?php
/*
Plugin Name: Stop Multiple WooCommerce Coupons
Plugin URI: https://metorik.com
Description: Only allow individual use coupons in WooCommerce, even if they have not been set as such.
Version: 1.0.0
Author: Bryce Adams (Metorik)
Author URI: https://metorik.com
Text Domain: stop-multiple-woocommerce-coupons-metorik
*/
View shipping.css
.shipping-calculator-form {
display: block !important;
}