Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / add-a-dropdown-to-filter-orders-by-state-and-country-into-shop-order-list-admin-woocommerce.php
Last active March 6, 2024 17:44
Add a dropdown to filter orders by state and country into shop order list admin - Woocommerce
<?php
// Aggiungi un menu a discesa per filtrare gli ordini per stato e nazione
add_action('restrict_manage_posts', 'add_shop_order_filter_by_state_and_country');
function add_shop_order_filter_by_state_and_country(){
global $pagenow, $typenow;
if( 'shop_order' === $typenow && 'edit.php' === $pagenow ) {
// Ottieni i codici dei paesi disponibili con i codici/nomi degli stati
$nazioni = WC()->countries->get_allowed_country_states();
@FrancoStino
FrancoStino / additional-extra-order-filters-for-woo-commerce.php
Created October 1, 2022 14:57
Additional Extra Order Filters for WooCommerce
<?php
if ( ! defined( 'ABSPATH' ) ) exit();
/*
Plugin Name: Additional Order Filters for WooCommerce
Description: Adds additional order filters for WooCommerce
Version: 1.10
Author: Anton Bond
Author URI: facebook.com/antonbondarevych
License: GPL2
@FrancoStino
FrancoStino / calculate-quantity-by-single-item-product-into-order-admin-page-through-bulk-action-selection-filter-woocommerce.php
Last active October 11, 2022 14:00
Calculate quantity by single item product into order admin page through bulk action selection (filter) - Woocommerce
<?php
// Display the custom actions on admin Orders bulk action dropdown
add_filter('bulk_actions-edit-shop_order', 'orders_bulk_action_delivery_collect_calc');
function orders_bulk_action_delivery_collect_calc($bulk_actions)
{
$bulk_actions['delivery-collect'] = __("Calcolo quantità degli ordini", 'woocommerce');
return $bulk_actions;
}
@FrancoStino
FrancoStino / register-a-new-column-that-will-show-if-an-order-was-a-first-order-for-a-customer-woocommerce.php
Last active October 1, 2022 08:17
Register a new column that will show if an order was a first order for a customer - Woocommerce
<?php
// Register a new column that will show if an order was a first order for a customer
add_filter( 'manage_edit-shop_order_columns', 'register_is_first_order_column', 10, 1 );
function register_is_first_order_column( $columns ) {
$columns['is_first_order'] = 'Primo ordine';
return $columns;
}
// Show a checkmark emoji in the column if it's true
add_action( 'manage_shop_order_posts_custom_column', 'display_is_first_order_column', 10, 1 );
@FrancoStino
FrancoStino / programmatically-apply-a-coupon-in-woo-commerce-for-first-order-made-by-a-customer.php
Last active May 5, 2023 07:45
Programmatically apply a coupon in WooCommerce for first order made by a customer
<?php
/**
* First Order Coupon Manager for WooCommerce
*/
class FirstOrderCouponManager
{
public function __construct(){}
@FrancoStino
FrancoStino / add-remove-item-and-quantity-field-to-woo-commerce-checkout-page.php
Last active September 28, 2022 08:33
Add remove item and quantity field to WooCommerce Checkout page
<?php
// Concatenate remove link after item qty
function filter_woocommerce_checkout_cart_item_quantity( $product_quantity, $cart_item, $cart_item_key ) {
// Trash icon remove item
$remove_link = apply_filters('woocommerce_cart_item_remove_link', sprintf(
'<a href="%s" rel="nofollow" class="remove"><svg style="color: red; margin-left: 10px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"> <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z" fill="red"></path> <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z" fill="red"></path> </svg></a>', esc_url(wc_get_cart_remove_url($cart_item_key)),
__('R
@FrancoStino
FrancoStino / add-remove-item-to-woo-commerce-checkout-page.php
Created September 26, 2022 08:26
Add Remove Item to WooCommerce Checkout page
<?php
// Concatenate remove link after item qty
function filter_woocommerce_checkout_cart_item_quantity( $item_qty, $cart_item, $cart_item_key ) {
$remove_link = apply_filters('woocommerce_cart_item_remove_link',
sprintf(
'<a href="#" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s" data-cart_item_key="%s"><svg style="color: red; margin-left: 10px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16"> <path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z" fill="red"></path> <path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z" fill="red"></path> </svg>
</a>',
__( 'Remove this
@FrancoStino
FrancoStino / rename-coupon-code-text-in-woocommerce.php
Created September 6, 2022 12:23
Rename Coupon Code Text in WooCommerce
<?php
add_filter( 'gettext', 'bt_rename_coupon_field_on_cart', 10, 3 );
add_filter( 'woocommerce_coupon_error', 'bt_rename_coupon_label', 10, 3 );
add_filter( 'woocommerce_coupon_message', 'bt_rename_coupon_label', 10, 3 );
add_filter( 'woocommerce_cart_totals_coupon_label', 'bt_rename_coupon_label',10, 1 );
add_filter( 'woocommerce_checkout_coupon_message', 'bt_rename_coupon_message_on_checkout' );
/**
* WooCommerce
* Change Coupon Text
@FrancoStino
FrancoStino / hide-opacity-certain-element-on-sroll-width-id-class-css-script.php
Last active September 9, 2022 07:27
Hide opacity certain element on sroll width ID class css script
<?php
/*
* Hide opacity certain element on sroll width ID class css script
*/
add_action('wp_footer', 'add_this_script_footer');
function add_this_script_footer(){?>
<script>
@FrancoStino
FrancoStino / custom-field-shipping-text-single-product.php
Last active September 7, 2022 10:46
Custom Field Shipping Text Single Product - Woocommerce
<?php
// Display Product settings Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
function woo_add_custom_general_fields() {
woocommerce_wp_text_input( array(
'id' => '_spedizione_gg',
'label' => __( 'Note Spedizione', 'woocommerce' ),
'placeholder' => 'Spedito tra...',
'desc_tip' => 'true',