Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / conditional-coupon-discount.php
Last active October 23, 2020 10:28
Coupon / Sconti condizionali ordine minimo Woocommerce
<?php
/////////////////////////////////////////// COUPON CONDIZIONALI /////////////////////////////////////////////////////
/**
* @snippet Add A Coupon Dynamically based on Cart Subtotal with WooCommerce
* @sourcecode http://hirejordansmith.com
* @author Davide Ladisa
* @compatible WooCommerce 2.4.7
*/
@FrancoStino
FrancoStino / code.php
Created December 1, 2020 14:13
Woocommerce Remove excerpt from single product and move description to excerpt
<?php
/*
* Woocommerce Remove excerpt from single product
*/
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
add_action( 'woocommerce_single_product_summary', 'the_content', 20 );
?>
@FrancoStino
FrancoStino / Always Display Single Variation Price @ WooCommerce Single Product Page.php
Created December 1, 2020 14:53
Always Display Single Variation Price @ WooCommerce Single Product Page
<?php
/**
* @snippet Always Show Variation Price @ WooCommerce Single Product
* @how-to Watch tutorial @ https://businessbloomer.com/?p=19055
* @sourcecode https://businessbloomer.com/?p=101266
* @author Rodolfo Melogli
* @compatible WooCommerce 3.5.3
* @donate $9 https://businessbloomer.com/bloomer-armada/
*/
@FrancoStino
FrancoStino / add-a-quick-buy-now-checkout-button-into-single-product-page-and-shop-loop-item-woocommerce.php
Last active November 9, 2023 14:35
Add a quick buy now checkout button into single product page and shop loop item - Woocommerce
<?php
/*
* Add a quick buy now checkout button in woocommerce into single product page and shop loop item
*/
add_action( 'woocommerce_after_shop_loop_item', 'add_custom_addtocart_and_checkout', 10 );
add_action( 'woocommerce_after_add_to_cart_button', 'add_custom_addtocart_and_checkout' );
function add_custom_addtocart_and_checkout() {
global $product;
@FrancoStino
FrancoStino / Add extra charge on shipping rate for each KG weight on cart.php
Last active January 13, 2021 15:39
Add extra charge on shipping rate for each KG weight on cart
<?php
/**
* Add extra charge on shipping rate for each KG weight on cart
*/
add_filter( 'woocommerce_package_rates', 'custom_delivery_flat_rate_cost_calculation', 10, 2 );
function custom_delivery_flat_rate_cost_calculation( $rates, $package )
{
// The total cart items weight
$cart_weight = WC()->cart->get_cart_contents_weight();
@FrancoStino
FrancoStino / Add extra charge on shipping rate for each KG weight on cart by zone.php
Created January 13, 2021 16:25
Add extra charge on shipping rate for each KG weight on cart by zone
<?php
/**
* Add extra charge on shipping rate for each KG weight on cart based by zone
*/
add_filter( 'woocommerce_package_rates', 'custom_delivery_flat_rate_cost_calculation_by_zone', 10, 2 );
function custom_delivery_flat_rate_cost_calculation_by_zone( $rates, $package )
{
// The total cart items weight
$cart_weight = WC()->cart->get_cart_contents_weight();
@FrancoStino
FrancoStino / Add Free shipping conditionally with certain category on cart and minimum order.php
Last active January 22, 2021 13:30
Add Free shipping conditionally with certain category on cart and minimum order
<?php
/**
* Add Free shipping conditionally with certain category on cart and minimum order
*/
add_filter( 'woocommerce_package_rates', 'hide_shipping_flat_rate_conditionaly', 90, 2 );
function hide_shipping_flat_rate_conditionaly( $rates, $package ){
// HERE Define your product category (ID, slug or name or an array of values)
$term = '52'; ## ID Categoria prodotto
@FrancoStino
FrancoStino / Add unitary price into select variation.php
Created January 15, 2021 16:30
Add unitary price into select variation
<?php
/*
* Add unitary price into select variation
*/
add_filter( 'woocommerce_variation_option_name', 'display_price_in_variation_option_name' );
function display_price_in_variation_option_name( $term ) {
global $wpdb, $product;
@FrancoStino
FrancoStino / Discount as fee at first order exclude product on sale and if is applied a coupon disable fee.php
Last active May 31, 2021 12:24
Discount as fee at first order exclude product on sale and if is applied a coupon disable fee
<?php
/**
* Discount as fee at first order exclude product on sale and if is applied a coupon disable fee
*/
add_action('woocommerce_cart_calculate_fees' , 'custom_discount', 10, 1);
function custom_discount( $cart ){
@FrancoStino
FrancoStino / Automatically Update Cart on Quantity Change - WooCommerce.php
Last active January 28, 2022 14:27
Automatically Update Cart on Quantity Change - WooCommerce
<?
/**
* Automatically Update Cart on Quantity Change - WooCommerce
*/
add_action( 'wp_footer', 'bbloomer_cart_refresh_update_qty' );
function bbloomer_cart_refresh_update_qty() {