All New

user:thomas gists created by user

title:mygist gists with given title

filename:myfile.txt gists having files with given name

extension:yml gists having files with given extension

language:go gists having files with given language

Login


All New

All gists

Recently created
Least recently created
Recently updated
Least recently updated
Malin's Avatar

Malin / filtered-cats-QRh.php

0 likes
0 forks
1 files
Last active 1713290640
1 function your_theme_enqueue_scripts() {
2 wp_enqueue_script('jquery');
3 // Add here any other scripts you need to enqueue
4 }
5
6 add_action('wp_enqueue_scripts', 'your_theme_enqueue_scripts');
7
8 function load_filtered_cats() {
9 // Security check
10 if (!check_ajax_referer('load_cats_nonce', 'nonce', false)) {
Malin's Avatar

Malin / sale-flash-label.php

0 likes
0 forks
1 files
Last active 1713290588
1 /* START Show sale flash label */
2 add_filter('woocommerce_sale_flash', 'ds_change_sale_text');
3 function ds_change_sale_text() {
4 return '<span class="onsale">Oferta!</span>';
5 }
6
7 /* END Show sale flash label */
Malin's Avatar

Malin / user-email-in-header.php

0 likes
0 forks
1 files
Last active 1713290559
1 /* START Display user email in header */
2 function show_user_email_shortcode() {
3 if ( is_user_logged_in() ) {
4 $current_user = wp_get_current_user();
5 return $current_user->user_email;
6 } else {
7 return ''; // Return an empty string if the user is not logged in
8 }
9 }
10 add_shortcode('show_user_email', 'show_user_email_shortcode');
Malin's Avatar

Malin / brand-above-title-in-cart.php

0 likes
0 forks
1 files
Last active 1713290488
1 /* START Display Brand above title in cart */
2 // Function to display child category above product title on cart page
3 function display_child_category_above_product_title_on_cart( $item_name, $cart_item, $cart_item_key ) {
4 // We attempt to check if $cart_item contains product details
5 if ( isset( $cart_item['product_id'] ) ) {
6 $product_id = $cart_item['product_id'];
7
8 // Get child categories of the product
9 $product_categories = get_the_terms( $product_id, 'product_cat' );
Malin's Avatar

Malin / unique-product-count-in-cart.php

0 likes
0 forks
1 files
Last active 1713290439
1 /* START Unique product count in cart */
2 // Shortcode to display the number of unique products in the cart with styling
3 function display_unique_cart_product_count_styled() {
4 // Initialize an empty array to store unique product IDs
5 $unique_product_ids = array();
6
7 // Get the cart contents
8 $cart_contents = WC()->cart->get_cart();
9
10 // Loop through each item in the cart
Malin's Avatar

Malin / custom-add-to-cart-button.php

0 likes
0 forks
1 files
Last active 1713290309
1 /* START custom add to cart button on home */
2 function custom_add_to_cart_button_with_icon() {
3 // Remove the default add to cart button
4 remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10);
5
6 // Add the new custom button
7 add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart_with_icon', 10);
8 }
9
10 function woocommerce_template_loop_add_to_cart_with_icon() {
Malin's Avatar

Malin / change-products-per-page.php

0 likes
0 forks
1 files
Last active 1713290210
1 add_action( 'pre_get_posts', 'custom_woocommerce_products_per_page' );
2
3 function custom_woocommerce_products_per_page( $query ) {
4 // Check if we're on a WooCommerce shop page or product category or tag page and if it's the main query
5 if( !is_admin() && $query->is_main_query() && (is_woocommerce() || is_product_category() || is_product_tag()) ) {
6 $query->set( 'posts_per_page', 9 ); // Set the number of products per page to 12
7 }
8 }
9
Malin's Avatar

Malin / change-read-more-and-disable-button.php

0 likes
0 forks
1 files
Last active 1713290098
1 // Change "Read More" text to "Out of Stock" for out-of-stock products
2 add_filter( 'woocommerce_product_add_to_cart_text', 'change_read_more_text_for_out_of_stock_products', 10, 2 );
3 function change_read_more_text_for_out_of_stock_products( $text, $product ) {
4 if ( !$product->is_in_stock() ) {
5 return 'No disponible'; // Change the text as needed
6 }
7 return $text;
8 }
9
10 // Remove the link of the "Add to Cart" / "Select options" / "Read More" button for out-of-stock products
Malin's Avatar

Malin / hide-0-stock-no-image.php

0 likes
0 forks
1 files
Last active 1713290035
1 add_action('woocommerce_product_query', 'hide_products_without_image_and_zero_stock');
2
3 function hide_products_without_image_and_zero_stock($q) {
4 $meta_query = $q->get('meta_query');
5
6 // Condition to check for products with an image
7 $meta_query[] = array(
8 'key' => '_thumbnail_id',
9 'compare' => 'EXISTS' // Ensures the product has an associated image
10 );
Malin's Avatar

Malin / custom-checkout-fields.php

0 likes
0 forks
1 files
Last active 1713289911
1 // Add a custom checkout fields for QRh, Tipo Cliente & NIF/CIF/NIE/DNI and save them to the database as META data
2
3 /**
4 * Add a 'Tipo cliente' dropdown field to the WooCommerce checkout page with specific options
5 */
6 add_filter('woocommerce_checkout_fields', 'custom_add_tipo_cliente_dropdown');
7 function custom_add_tipo_cliente_dropdown($fields) {
8 $fields['billing']['billing_tipo_cliente'] = array(
9 'type' => 'select',
10 'label' => __('Tipo cliente', 'woocommerce'),
Newer Older

Powered by Opengist ⋅ Load: 778ms⋅

English
Čeština Deutsch English Español Français Magyar Português Русский 中文 繁體中文