Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / gforms-merge-tag.php
Last active July 20, 2023 13:50 — forked from hereswhatidid/gforms-merge-tag.php
Create a custom Gravity Forms merge tag
<?php
/**
* Add custom merge tag to the merge tags drop down in the form editor
*
* @param array $merge_tags
* @param int $form_id
* @param array $fields
* @param int $element_id
*
* @return array
@FrancoStino
FrancoStino / woocommerce-update-prices.sql
Last active September 16, 2023 09:26 — forked from yanknudtskov/woocommerce-update-prices.sql
Queries for updating all prices including variations in WooCommerceIn this instance all prices are subtracted 20% (0.8)#woocommerce #mysql
-- Queste query SQL aggiornano tutti i prezzi, comprese le variazioni, in WooCommerce.
-- In questo caso, tutti i prezzi vengono scontati del 20% (moltiplicati per 0.8).
-- Aggiorna il prezzo regolare se il valore esiste e la chiave meta è '_regular_price'.
UPDATE wpjd_postmeta SET meta_value = meta_value * 0.8 WHERE meta_key = '_regular_price' AND meta_value != '';
-- Aggiorna il prezzo in offerta se il valore esiste e la chiave meta è '_sale_price'.
UPDATE wpjd_postmeta SET meta_value = meta_value * 0.8 WHERE meta_key = '_sale_price' AND meta_value != '';
-- Aggiorna il prezzo se il valore esiste e la chiave meta è '_price'.
@FrancoStino
FrancoStino / sorting_in_variations_dropdown.php
Last active September 21, 2024 10:03 — forked from qzya/sorting_in_variations_dropdown.php
[Sort product attributes in variations dropdown on single page by backend variations order ] #wp #woocommerce #products #product_attributes #sorting #terms #variations
<?php
// Aggiungi un filtro per modificare l'HTML del menu a tendina per le opzioni di variazione degli attributi
add_filter('woocommerce_dropdown_variation_attribute_options_html', 'wc_dropdown_variation_attribute_options_sorted', 20, 2);
// Funzione per ordinare le opzioni di variazione degli attributi
function wc_dropdown_variation_attribute_options_sorted( $html, $args ) {
// Analizza gli argomenti con i valori predefiniti
$args = wp_parse_args(
apply_filters( 'woocommerce_dropdown_variation_attribute_options_args', $args ),
@FrancoStino
FrancoStino / export-customers-who-have-placed-orders-in-a-csv-file.php
Last active April 4, 2023 13:39
Export customers who have placed orders in a CSV file
<?php
/*
* Esporta i clienti che hanno effettuato gli ordini in un file CSV
*/
function export_customers_to_csv() {
ob_end_clean();
ob_start();
@FrancoStino
FrancoStino / add-featured-image-background-wp-bakery.php
Created March 31, 2023 08:49
Add Featured Image background - WPBakery
@FrancoStino
FrancoStino / query-sql-per-identificare-gli-shortcode-contenenti-l-id-del-prodotto-nella-breve-descrizione-di-ogni-prodotto-e-rimuoverli-woocommerce.sql
Created March 30, 2023 11:41
Query SQL per identificare gli shortcode contenenti l'id del prodotto nella breve descrizione di ogni prodotto e rimuoverli - Woocommerce
UPDATE wp154_posts
SET post_excerpt = REPLACE(post_excerpt,
SUBSTRING(post_excerpt,
LOCATE('[iw_product_price id=', post_excerpt),
LOCATE(']', post_excerpt, LOCATE('[iw_product_price id=', post_excerpt)) - LOCATE('[iw_product_price id=', post_excerpt) + 1
),
''
)
WHERE post_type = 'product' AND post_excerpt LIKE '%[iw_product_price id=%';
@FrancoStino
FrancoStino / grid-image-ratio-woocommerce-product.css
Last active November 18, 2023 11:00
Grid Image Ratio Woocommerce Product - CSS
.product-wrapper img {
width: 100%;
height: 300px !important;
object-fit: contain;
}
@FrancoStino
FrancoStino / Installare MPFD nel Cpanel tramite linea di comando.txt
Created March 26, 2023 10:50
Installare MPFD nel Cpanel tramite linea di comando
Installazione
1) wget https://getcomposer.org/installer
2) php installer
3) php composer.phar
// "cd" directory preferita
@FrancoStino
FrancoStino / send-an-email-when-added-order-note-containing-tracking-shipping-code-gls-woocommerce.php
Last active July 18, 2023 13:41
Send an email when added order note containing tracking shipping code (GLS) - Woocommerce
<?php
// Send an email when added order note containing tracking code (GLS)
add_action( 'woocommerce_order_note_added', 'woocommerce_order_notes_notification', 10, 2);
function woocommerce_order_notes_notification( $note_id, $order ) {
// recupera l'oggetto nota e l'ID dell'ordine associato
$note = wc_get_order_note( $note_id );
$order_id = $note->order_id;
@FrancoStino
FrancoStino / capitalize-title-product-on-save-automatically-woocommerce.php
Created March 23, 2023 09:32
Capitalize Title Product on save automatically - Woocommerce
<?php
// Definiamo la funzione che sarà chiamata quando viene salvato un prodotto
function my_capitalize_product_title( $product_id ) {
// Recuperiamo il prodotto dal suo ID
$product = wc_get_product( $product_id );
// Recuperiamo il titolo del prodotto
$title = $product->get_title();