Skip to content

Instantly share code, notes, and snippets.

View mircobabini's full-sized avatar

Mirco Babini mircobabini

View GitHub Profile
<?php
add_filter( 'pmpro_include_billing_address_fields', function ( $include ) {
// if someone forced to include the fields
// but it's set to NOT include them in settings
// and Stripe Checkout is active
// and Stripe Checkout is set to include billing address fields on its checkout page
// => don't include them, bc it's a conflict with some other add-on or snippet
if ( $include && ! pmpro_getOption( "stripe_billingaddress" ) && 'checkout' === pmpro_getOption( 'stripe_payment_flow' ) && pmpro_getOption( 'stripe_checkout_billing_address' ) ) {
$include = false;
<?php
add_filter( 'iubenda_initial_output', function ( $final_output ) {
// https://www.tagmanageritalia.it/guida-gdpr-disabilitare-cookie-youtube-e-google-maps/
$final_output = str_replace( 'maps.google.com', 'maps.googleapis.com', $final_output );
$final_output = str_replace( 'www.google.com/maps', 'maps.googleapis.com/maps', $final_output );
return $final_output;
} );
<?php
add_action( 'wpo_wcpdf_billing_address', function ( $billing_address, $invoice ) {
if ( ! empty( $invoice ) ) {
$billing_address_prefix = '';
// billing_company
$company_name = trim( $invoice->order->get_meta( '_billing_company', true, 'view' ) );
if ( ! empty( $company_name ) ) {
$billing_address_prefix .= "<b>$company_name</b><br>";
}
@mircobabini
mircobabini / wc-wpo-wcpdf-billing-address-company-vat-advanced.php
Last active February 14, 2023 17:46
In order to use the "additional" fields feature, the premium version of the plugin is required. Check the simple version otherwise: https://gist.github.com/mircobabini/64ead066b22575f6948d133c82500555
<?php
add_action( 'wpo_wcpdf_billing_address', function ( $billing_address, $invoice ) {
if ( ! empty( $invoice ) ) {
$customer_type = $invoice->order->get_meta( '_additional_wooccm0', true, 'view' );
if ( 'Azienda' === $customer_type ) {
$company_name = $invoice->order->get_meta( '_additional_wooccm1', true, 'view' );
$company_vat = $invoice->order->get_meta( '_additional_wooccm2', true, 'view' );
$billing_address_prefix = "";
<?php
define( 'INVOICE_GENERATION_MINIMUM_SUBTOTAL', 100 ); // se subtotale >= X€ IVA ESCUSA, allora genero la fattura
add_filter( 'wpo_wcpdf_document_is_allowed', function ( $allowed, $document ) {
if ( ! $document->exists() && ! empty( $order = $document->order ) ) {
if ( ! is_callable( array( $order, 'get_subtotal' ) ) ) {
return false;
}
// check order total & setting
$order_subtotal = $order->get_subtotal();
@mircobabini
mircobabini / wc-sell-or-ship-to-specific-countries-europe.sql
Last active February 9, 2023 08:27 — forked from pascalknecht/query.sql
WooCommerce sell/ship EU Countries only (small area, extended area or the whole continent)
# Sell to specific EU countries only
UPDATE `wp_options` SET `option_value`='specific' WHERE option_name = 'woocommerce_allowed_countries';
UPDATE `wp_options` SET `option_value`='a:30:{i:0;s:2:"AT";i:1;s:2:"BE";i:2;s:2:"BG";i:3;s:2:"HR";i:4;s:2:"CY";i:5;s:2:"CZ";i:6;s:2:"DK";i:7;s:2:"EE";i:8;s:2:"FI";i:9;s:2:"FR";i:10;s:2:"DE";i:11;s:2:"GR";i:12;s:2:"HU";i:13;s:2:"IE";i:14;s:2:"IM";i:15;s:2:"IT";i:16;s:2:"JE";i:17;s:2:"LV";i:18;s:2:"LT";i:19;s:2:"LU";i:20;s:2:"MT";i:21;s:2:"NL";i:22;s:2:"PL";i:23;s:2:"PT";i:24;s:2:"RO";i:25;s:2:"SK";i:26;s:2:"SI";i:27;s:2:"ES";i:28;s:2:"SE";i:29;s:2:"GB";}' WHERE option_name = 'woocommerce_specific_allowed_countries';
# Ship to specific EU countries only
UPDATE `wp_options` SET `option_value`='specific' WHERE option_name = 'woocommerce_ship_to_countries';
UPDATE `wp_options` SET `option_value`='a:30:{i:0;s:2:"AT";i:1;s:2:"BE";i:2;s:2:"BG";i:3;s:2:"HR";i:4;s:2:"CY";i:5;s:2:"CZ";i:6;s:2:"DK";i:7;s:2:"EE";i:8;s:2:"FI";i:9;s:2:"FR";i:10;s:2:"DE";i:11;s:2:"GR";i:12;s:2:"HU";i:13
<?php
/**
* Plugin Name: SED Web - Scheduled Post Trigger
* Description: Publishes scheduled posts that were missed by cron at defined interval
* Plugin URI:
* Version: 1.4.0
* Requires at least: 4.9
* Requires PHP: 5.6
* License: GPLv2 or later
* Author: SED Web
{
"name": "vendor_name/site-composer-based",
"description": "description",
"minimum-stability": "stable",
"license": "proprietary",
"authors": [
{
"name": "mircobabini",
"email": "[email protected]"
}
<?php
/**
* Grant access to the back-end to certain user roles
*
* @param bool $prevent_admin_access
*
* @return bool
*/
function pmpro_grant_admin_access_to_dataanalyst( $prevent_admin_access ) {
if ( current_user_can( 'dataanalyst' ) ) {
@mircobabini
mircobabini / variation-duplicator-for-woocommerce-disable-image-duplicator.php
Last active June 14, 2022 09:12
UPDATE: useless from 2.0.4+ thanks to the new filter disable_variation_duplicator_for_woocommerce_image_clone
<?php
/**
* Plugin Name: Duplicate Variations for WooCommerce (Disable Image Duplicator)
* Description: Disattiva la funzionalità di "image duplicator" che rallenta il loading delle variazioni
* Author: Mirco Babini
* Domain Path: /languages
* Version: 2.0.3
* Author URI: https://sedweb.com/
*/
add_action( 'variation_duplicator_for_woocommerce_variation_image_clone_loaded', function ( $instance ) {