Skip to content

Instantly share code, notes, and snippets.

View Spirecool's full-sized avatar

Jérôme OLLIVIER Spirecool

View GitHub Profile
//Code to display ACF checkboxes as list
add_shortcode('acfBr', 'brListFunction');
function brListFunction($atts, $content) {
extract(shortcode_atts(array("id"=>'','field'=>''),$atts));
if($field){
if($id=''){
global $post;
$id=$post->ID;
}
<?php
add_action( 'woocommerce_before_shop_loop_item_title', 'popcorn_new_badge_shop_page', 3 ); // on commence par la position où va se trouver le badge, puis on créé une fonction
function popcorn_new_badge_shop_page() {
global $product;
$newness_days = 30; //ici on met le nombre jours, nouveautés sur les 30 derniers jours dans ce cas présent
$created = strtotime( $product->get_date_created() );
if ( ( time() - ( 60 * 60 * 24 * $newness_days ) ) < $created ) {
echo '<span class="itsnew onsale">' . esc_html__( 'Nouveauté!', 'woocommerce' ) . '</span>';
<?php
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 9 //ici on met le nombre d'articles que l'on souhaite voir par page
return $cols;
<?php
* Change number or products per row to 3
*/
add_filter('loop_shop_columns', 'loop_columns', 999);
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
Modifier le nombre de produtis par colonne dans la page Archives
[recent_products per_page="12" columns="5"] will display the products in rows of 5 columns.
//À utiliser dans la page du Panier
[woocommerce_cart]
<?php
add_filter( 'woocommerce_breadcrumb_defaults', 'jk_woocommerce_breadcrumbs' );
function jk_woocommerce_breadcrumbs() {
return array(
'delimiter' => ' &#47; ',
'wrap_before' => '<nav class="woocommerce-breadcrumb" itemprop="breadcrumb">',
'wrap_after' => '</nav>',
'before' => '',
'after' => '',
<?php
add_action( 'init', 'woo_remove_wc_breadcrumbs' );
function woo_remove_wc_breadcrumbs() {
remove_action( 'woocommerce_before_main_content', 'woocommerce_breadcrumb', 20, 0 );
}
Pour StoreFront, remplacer :
add_action( 'init', 'wc_remove_storefront_breadcrumbs');
<?php
add_action( 'woocommerce_after_order_notes', 'bbloomer_notice_shipping' );
function bbloomer_notice_shipping() {
echo '<p class="allow">Please allow 5-10 business days for delivery after order processing.</p>';
}