Skip to content

Instantly share code, notes, and snippets.

View corsonr's full-sized avatar

Remi Corson corsonr

View GitHub Profile
@corsonr
corsonr / gist:9071214
Created February 18, 2014 13:42
WooCommerce - Store terms and conditions value within the database
<?php
/**
* Store terms and conditions value within the database
**/
add_action('woocommerce_checkout_update_order_meta', 'woo_save_terms_and_conditions_status');
function woo_save_terms_and_conditions_status( $order_id ) {
if ($_POST['terms']) update_post_meta( $order_id, '_terms', esc_attr($_POST['terms']));
}
@corsonr
corsonr / gist:9132329
Created February 21, 2014 10:47
WooCommerce : search by sku in admin (temporary fix)
<?php
/**
* Search by SKU or ID for products. Adapted from code by BenIrvin (Admin Search by ID)
*
* @access public
* @param mixed $wp
* @return void
*/
function woocommerce_admin_product_search( $wp ) {
global $pagenow, $wpdb;
@corsonr
corsonr / gist:9597159
Created March 17, 2014 10:40
jQuery UI Datepicker French localization
/* French initialisation for the jQuery UI date picker plugin. */
/* Written by Keith Wood (kbwood{at}iinet.com.au),
Stéhane Nahmani (sholby@sholby.net),
Stéphane Raimbault <stephane.raimbault@gmail.com> */
jQuery(function($){
$.datepicker.regional['fr'] = {
closeText: 'Fermer',
prevText: 'Précédent',
nextText: 'Suivant',
currentText: 'Aujourd\'hui',
@corsonr
corsonr / gist:9969721
Last active August 29, 2015 13:58
WooCommerce - is user a paying customer?
<?php
/**
* Is the user a paying customer?
*
* @access public
* @return bool
*/
function is_paying_customer( $user_id ) {
@corsonr
corsonr / gist:101d4fa2c7178de9ca2a
Created May 20, 2014 08:36
WPdonations: Editing Submit Donation Form Fields
// Add your own function to filter the fields
add_filter( 'submit_donation_form_fields', 'custom_submit_donation_form_fields' );
// This is your function which takes the fields, modifies them, and returns them
// You can see the fields which can be changed in: includes/forms/class-wpdonations-form-submit-donation.php
function custom_submit_donation_form_fields( $fields ) {
// Here we target one of the donation fields (donation_amount) and change it's label
$fields['donation']['donation_amount']['label'] = "Custom Label";
@corsonr
corsonr / gist:5a619439eee6b57e6959
Last active August 29, 2015 14:01
WPdonations: Remove an Existing field
// Add your own function to filter the fields
add_filter( 'submit_donation_form_fields', 'remove_submit_donation_form_fields' );
// This is your function which takes the fields, modifies them, and returns them
// You can see the fields which can be changed in: includes/forms/class-wpdonations-form-submit-donation.php
function remove_submit_donation_form_fields( $fields ) {
// Here we remove one of the donation fields (donation_campaign)
unset($fields['donation']['donation_campaign']);
@corsonr
corsonr / gist:35dbc4ea73a1708ea69c
Last active August 29, 2015 14:01
WPdonations: Add a New Custom field
// Add your own function to filter the fields
add_filter( 'submit_donation_form_fields', 'add_submit_donation_form_fields' );
// This is your function which takes the fields, modifies them, and returns them
// You can see the fields which can be changed in: includes/forms/class-wpdonations-form-submit-donation.php
function add_submit_donation_form_fields( $fields ) {
// Here we register the new field
$fields['donor']['donor_phone'] = array(
'label' => __('Phone', 'wpdonations'),
@corsonr
corsonr / gist:5b03c73c58a85183338d
Last active August 29, 2015 14:01
WPdonations: change progress bar color
.progress.striped .bar {
background-color: #e844b4 !important;
}
@corsonr
corsonr / gist:da403299fc991c49dad9
Created May 30, 2014 13:41
WPdonations: edit available donations amounts
add_filter( 'donation_available_amounts', 'my_custom_amounts' );
function my_custom_amounts() {
$options = array(
'5' => '5',
'10' => '10',
'20' => '20',
'30' => '30',
'40' => '40',
'50' => '50'
@corsonr
corsonr / gist:0f19caaacfaa2c6b934f
Created June 14, 2014 10:06
WooCommerce : display category image on category archive
<?php
add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );
function woocommerce_category_image() {
if ( is_product_category() ){
global $wp_query;
$cat = $wp_query->get_queried_object();
$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
$image = wp_get_attachment_url( $thumbnail_id );