Skip to content

Instantly share code, notes, and snippets.

Remi Corson corsonr

Block or report user

Report or block corsonr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@corsonr
corsonr / gist:c9b03ee67425606365b17742ba3d0a2f
Created Feb 14, 2020
wp-cli: delete all WooCommerce products
View gist:c9b03ee67425606365b17742ba3d0a2f
wp post delete $(wp post list --post_type='product' --format=ids --posts_per_page=10000) --force
@corsonr
corsonr / functions.php
Created Dec 20, 2019
Restrict WooCommerce Subscriptions Creation Process
View functions.php
<?php
if ( current_user_can( 'edit_pages' ) ) { // Edit capability here.
remove_filter( 'product_type_selector', 'WC_Subscriptions_Admin::add_subscription_products_to_select' );
}
@corsonr
corsonr / functions.php
Created Aug 27, 2019
WooCommerce: redirect user upon coupon removal
View functions.php
<?php // Do not include this if already open! Code goes in theme functions.php.
/*
* Redirects user to a specific page upon coupon removal.
*/
function action_woocommerce_removed_coupon( $coupon_code ) {
// Redirection...
wp_redirect( $url ); // Replace $url by your page URL.
exit;
};
@corsonr
corsonr / functions.php
Created Jan 28, 2019
WooCommerce: display products discounted price in cart table
View functions.php
<?php
/*
* Display discounted products prices in the cart table.
*
* Modification of code provided here https://businessbloomer.com/woocommerce-display-cart-item-subtotal-coupon-discount/.
*/
add_filter( 'woocommerce_cart_item_subtotal', 'if_coupon_slash_item_subtotal', 99, 3 );
add_filter( 'woocommerce_cart_item_price', 'if_coupon_slash_item_subtotal', 99, 3 );
/**
@corsonr
corsonr / functions.php
Last active Sep 14, 2018
WooCommerce: set price to zero
View functions.php
<?php
function make_it_free() {
echo '<table class="variations" cellspacing="0">
<tbody>
<tr>
<td class="label"><label>Make this free!</label></td>
<td class="value">
<label><input type="checkbox" name="option_free" value="YES" /> Set price to zero</label>
</td>
</tr>
@corsonr
corsonr / functions.php
Created Jul 24, 2018
WooCommerce 360: slow down...
View functions.php
<?php // Do not include this if already open! Code goes in theme functions.php.
/*
* Slow down WooCommerce 360 images rotation.
*/
add_filter( 'wc360_js_playspeed', 'woo_slow_down360' );
function woo_slow_down360( $speed ) {
return 50;
}
@corsonr
corsonr / functions.php
Created Jul 13, 2018
WooCommerce: Add conditional checkout fields based on products in cart
View functions.php
<?php // Do not include this if already open! Code goes in theme functions.php.
/**
* Add fields to the checkout page based on products in cart.
*
* @how-to https://remicorson.com/?p=7871
* @author Remi Corson
* @testedwith WooCommerce 3.4.0
*/
@corsonr
corsonr / functions.php
Created Jun 29, 2018
WooCommerce Stripe: force customer creation in Stripe
View functions.php
<?php // Do not include this if already open! Code goes in theme functions.php.
/*
* Force customer creation process in Stripe.
*/
add_filter( 'wc_stripe_force_save_source', '__return_true' );
@corsonr
corsonr / oncefiller.user.js
Last active Mar 29, 2019
A8C - Once key field auto-filler
View oncefiller.user.js
// ==UserScript==
// @name A8C - Once key field auto-filler
// @namespace http://automattic.com/
// @version 0.1
// @description Pre-fill Once fields
// @author Remi Corson
// @match https://<place_mc_url_here>/once/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
@corsonr
corsonr / functions.php
Last active Feb 4, 2019
WooCommerce: remove products ordering dropdown select in shop page
View functions.php
<?php // Do not include this if already open! Code goes in theme functions.php.
/**
* Remove WooCommerce default catalog ordering from shop page.
*/
add_action( 'after_setup_theme', 'remove_woocommerce_catalog_ordering', 1 );
function remove_woocommerce_catalog_ordering() {
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 ); // If using Storefront, replace 30 by 10.
}
You can’t perform that action at this time.