Skip to content

Instantly share code, notes, and snippets.

View gregoirenoyelle's full-sized avatar

Grégoire Noyelle gregoirenoyelle

View GitHub Profile
@gregoirenoyelle
gregoirenoyelle / wc-add-new-country.php
Last active April 7, 2018 09:59 — forked from woogists/wc-add-new-country.php
Add a new country to countries list
<?php
add_filter( 'woocommerce_countries', 'gnwooc2_ajouter_pays' );
function gnwooc2_ajouter_pays( $countries ) {
$new_countries = array(
'NIRE' => __( 'Irlande du NORD', 'woocommerce' ),
);
return array_merge( $countries, $new_countries );
}
@gregoirenoyelle
gregoirenoyelle / wc-unhook-remove-emails.php
Last active April 7, 2018 09:48 — forked from woogists/wc-unhook-remove-emails.php
[General Snippets] Unhook and remove WooCommerce default emails.
<?php
/**
* Code goes in functions.php or a custom plugin.
*/
add_action( 'woocommerce_email', 'unhook_those_pesky_emails' );
function unhook_those_pesky_emails( $email_class ) {
/**
* Hooks for sending emails during store events
<?php // Ne pas mettre les balises PHP
// A placer dans le fichier functions.php de votre thème
// Placer le troisième menu dans le thème Before header
function wp3_appel_troisieme_menu() {
// Fonction pour afficher et configurer le menu
wp_nav_menu( array(
'theme_location' => 'troisieme-menu',
'container' => 'nav',
@gregoirenoyelle
gregoirenoyelle / woocom-enqueue-css.php
Last active January 21, 2018 08:11
Enqueue CSS pour WooCommerce
<?php
/**
* Enqueue CSS pour WooCommerce
*
* Les CSS déclarés dans votre thème seront chargés après ceux de WooCommerce
*
* @package Genesis Sample
* @author Grégoire Noyelle
* @license GPL-2.0+
*/
@gregoirenoyelle
gregoirenoyelle / woocom-genesis-wp-get-products-acf.php
Last active January 21, 2018 06:57
Boucle WooCommece sur mesure avec wp_get_products
<? // Template Name: Boutique avec options
/**
* Ajouter nouveau contenu
* @author Grégoire Noyelle
* @link https://github.com/woocommerce/woocommerce/wiki/wc_get_products-and-WC_Product_Query
* @link https://businessbloomer.com/woocommerce-easily-get-product-info-title-sku-desc-product-object/
*/
add_action( 'genesis_entry_content', 'woomod_nouveau_contenu', 20 );
@gregoirenoyelle
gregoirenoyelle / woocom-apply-filter-origine.php
Last active January 23, 2018 13:49
Exemples avec filter dans WooCommerce
<?php
//* Extrait de la fonction wp_add_to_cart_message dans le fichier woocommerce/includes/wc-cart-functions.php
//* Ici on se concentre sur le `apply_filters` pour la redirection native. Elle est éditable avec le hook.
// Output success messages
if ( 'yes' === get_option( 'woocommerce_cart_redirect_after_add' ) ) {
$return_to = apply_filters( 'woocommerce_continue_shopping_redirect', wc_get_raw_referer() ? wp_validate_redirect( wc_get_raw_referer(), false ) : wc_get_page_permalink( 'shop' ) );
$message = sprintf( '<a href="%s" class="button wc-forward">%s</a> %s', esc_url( $return_to ), esc_html__( 'Continue shopping', 'woocommerce' ), esc_html( $added_text ) );
} else {
<?php
/**
* The Template for displaying all single products
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
<?php
/*****
* Voir les hook dans les fichiers:
* /woocommerce/includes/wc-template-hooks.php
* Les fonctions sont ajoutées à un fichier dédié dans mon thème qui est appelé depuis le
* le fichier principal: functions.php
*/
// Ajout de texte avant les vignettes
<?php
//* A placer dans un fichier de function dans votre thème
/**
* Hook pour retirer du texte
* @author Grégoire Noyelle
* @note bien mettre le paramètre et la référence à la classe.
*/
<?php
// Move Jetpack Share
// Add to functions.php
// Hook in Genesis Meta
add_action( 'genesis_meta', 'vft_filtre_partage' );
function vft_filtre_partage() {
// Remove default sharing
remove_filter( 'the_excerpt', 'sharing_display', 19 );
remove_filter( 'the_content', 'sharing_display', 19 );