Skip to content

Instantly share code, notes, and snippets.

Avatar

Remi Corson corsonr

View GitHub Profile
@corsonr
corsonr / attestation-derogatoire.user.js
Last active Nov 7, 2020
Génération automatique de l'attestation dérogatoire obligatoire en France pour le confinement V2.
View attestation-derogatoire.user.js
// ==UserScript==
// @name Attestation Derogatoire
// @namespace https://media.interieur.gouv.fr/
// @version 0.1
// @description Auto-génération de l'attestation. Passez le motif en URL, par exemple https://media.interieur.gouv.fr/deplacement-covid-19/?raison=travail
// @author Remi Corson
// @match https://media.interieur.gouv.fr/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
@corsonr
corsonr / woo-restrict-ordersper-day.php
Last active May 6, 2020
WooCommerce - restrict number of orders per day
View woo-restrict-ordersper-day.php
<?php
/**
* Plugin Name: Restrict Orders per Day for WooCommerce
* Plugin URI: https://remicorson.com
* Description: Put the shop into catalogue mode once number of orders per day is reached.
* Version: 0.1
* Author: Remi Corson, corsonr
* Author URI: https://remicorson.com
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
@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' );
You can’t perform that action at this time.