Skip to content

Instantly share code, notes, and snippets.

View FrancoStino's full-sized avatar
🌞

Davide Ladisa FrancoStino

🌞
View GitHub Profile
@FrancoStino
FrancoStino / hide-tax-rate-label-on-subtotal-cart-checkout-and-into-email-order-if-tax-is-inclusive-woocommerce.php
Created December 10, 2022 16:47
Hide tax rate label on subtotal cart - checkout and into email order if tax is inclusive - Woocommerce
<?php
/*
* Hide tax rate label on subtotal cart - checkout and into email order if tax is inclusive - Woocommerce
*/
// For Cart and checkout pages
add_filter( 'woocommerce_cart_totals_order_total_html', 'hide_iternational_tax_label', 20 );
function hide_iternational_tax_label() {
@FrancoStino
FrancoStino / insert-suffix-jquery-if-tax-is-exempt-or-scorporate-iva-on-price-woocommerce-uni-cpo-builder.php
Last active June 24, 2023 09:33
Insert suffix Jquery if tax is exempt or scorporate IVA on price - Woocommerce UniCPO Builder
<?php
/**
* Insert suffix Jquery if tax is exempt Woocommerce UniCPO Builder
*/
add_filter( 'wp_footer', 'bbloomer_price_free_zero');
function bbloomer_price_free_zero() {
if ( ! is_product() ) {
@FrancoStino
FrancoStino / code-script-whatsapp-button-jquery.js
Last active December 9, 2022 10:41
Code script whatsapp button Jquery
function CreateWhatsappChatWidget(option = {
brandSetting: {
autoShow: true,
backgroundColor: "#0a6114",
borderRadius: "25",
brandImg: "https://cdn.clare.ai/wati/images/WATI_logo_square_2.png",
brandImgData: null,
brandName: "WATI",
brandSubTitle: "Typically replies within a day",
ctaText: "Start Chat",
@FrancoStino
FrancoStino / custom-price-message-meta-key-into-cart-item-iva-woocommerce.php
Last active December 7, 2022 13:12
Custom Price message meta key into cart item (IVA) - Woocommerce
<?php
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message', 10, 3 );
function kd_custom_price_message( $price_html, $cart_item, $cart_item_key ) {
if (!empty($cart_item['_cpo_calc_option'])) {
foreach ($cart_item as $key => $value) {
if(is_array($value)){
if(array_key_exists('uni_cpo_iva10', $value)) {
$afterPriceSymbol = ' <small class="tax_label">(IVA incl. 10%)</small>';
@FrancoStino
FrancoStino / adding-a-custom-text-under-the-x-button-that-removes-items-from-cart.php
Last active January 31, 2023 14:01
Adding a custom text under the X button that removes items from cart
<?php
add_filter('woocommerce_cart_item_remove_link', 'remove_icon_and_add_text', 10, 2);
function remove_icon_and_add_text($string, $cart_item_key) {
$string = str_replace('class="remove"', '', $string);
return str_replace('&times;', '<span class="remove-text" style="font-size:0.9em; display:block;">Rimuovi prodotto', $string);
}
@FrancoStino
FrancoStino / allow-percentage-and-only-type-number-input-field.php
Created November 26, 2022 20:52
Allow percentage and only type number input field
<?php
add_filter('wp_footer', 'allow_percentage_and_only_type_number_input_field');
function allow_percentage_and_only_type_number_input_field(){
// Only on the product page.
if ( ! is_product() ) {
return;
}
?>
@FrancoStino
FrancoStino / assign-parent-product-taxonomy-categories-when-child-term-taxonomy-is-set-woocommerce.php
Created November 20, 2022 11:42
Assign parent product taxonomy categories when child term taxonomy is set - Woocommerce
<?php
function set_product_parent_categories( $post_id ) {
$category = wp_get_post_terms( $post_id, 'product_cat' );
// If multiple categories are set. Bail Out
if (count ($category) > 1 ) return;
$terms = array($category[0]->term_id);
if ($category[0]->parent > 0){
$parent = $category[0]->parent;
@FrancoStino
FrancoStino / remove-price-schema-rank-math-in-the-open-graph-tags-and-schema-rich-snippets.php
Last active October 20, 2022 14:04
Remove price schema Rank Math in the OpenGraph tags and schema rich snippets
<?php
/**
* Allow developers to prevent the output of the price in the OpenGraph tags and schema rich snippets.
*
* @param bool unsigned Defaults to true.
*/
add_filter( 'rank_math/woocommerce/og_price', '__return_false' );
add_filter( 'rank_math/snippet/rich_snippet_product_entity', function( $entity ) {
if ( isset( $entity['offers'] ) ) {
unset( $entity['offers'] );
@FrancoStino
FrancoStino / custom-order-status-woocommerce.php
Last active December 19, 2022 15:37
Custom order status - Woocommerce
<?php
/**
* Rename "completed" Order Status to "shipped"
*/
add_filter( 'wc_order_statuses', 'bbloomer_rename_completed_order_status' );
function bbloomer_rename_completed_order_status( $statuses ) {
$statuses['wc-completed'] = 'Spedito';
@FrancoStino
FrancoStino / add-a-dropdown-to-filter-orders-by-date-range-into-shop-order-list-admin-woocommerce.php
Last active October 11, 2022 09:46
Add a dropdown to filter orders by date range into shop order list admin - Woocommerce
<?php
// Add a dropdown to filter orders by date range
add_action('restrict_manage_posts', 'add_shop_order_filter_by_date');
function add_shop_order_filter_by_date(){
global $pagenow, $typenow;
if( 'shop_order' === $typenow && 'edit.php' === $pagenow ) {
?>
<script>
jQuery(document).ready(function($) {
$( '#ant_filter_start_date' ).datepicker({