Skip to content

Instantly share code, notes, and snippets.

@WpComet
WpComet / gist:19e370872d50ad82efab5a228fbb5ef3
Last active February 11, 2024 10:33
Convert woocommerce catalog ordering from dropdown to buttons
document.addEventListener('DOMContentLoaded', function () {
// Check if we're on a product category archive page
if (document.body.classList.contains('archive') && document.body.classList.contains('woocommerce')) {
// Get a reference to the select element
const sortingSelect = document.querySelector('.woocommerce-ordering select');
// Hide the default select box
sortingSelect.style.display = 'none';
// Create a new div for the sorting buttons
@WpComet
WpComet / gist:70c6c122b68d4c2770365545ca625b4d
Created August 20, 2023 20:51
SweetAlert - Swal defaults
const defaultParams = {
title: '',
titleText: '',
text: '',
html: '',
footer: '',
icon: undefined,
iconColor: undefined,
iconHtml: undefined,
template: undefined,
@WpComet
WpComet / gist:f0616a0a503f61fa1d7d643e83c6660a
Created August 8, 2023 09:54
Dismissing a stuck woocommerce notice
add_action( 'admin_notices', 'fix_wc_notice_472021' );
/*
* Change notice 'name' as needed.
*/
function fix_wc_notice_472021() {
global $wpdb;
$wpdb->update( $wpdb->prefix . 'wc_admin_notes', ['status'=>'actioned'], ['name'=>'woocommerce-core-paypal-march-2022-updated'] );
}
@WpComet
WpComet / gist:4a802a56817448e3dd425b2efcad294f
Created September 17, 2021 10:03
Making woocommerce product gallery autoplay
add_filter( 'woocommerce_single_product_carousel_options', 'filter_single_product_carousel_options' );
function filter_single_product_carousel_options( $options ) {
    $options['slideshow'] = true;
    $options['animationLoop'] = true;
    $options['slideshowSpeed'] = 3000;
    return $options;
}