Skip to content

Instantly share code, notes, and snippets.

View seoindex's full-sized avatar

seoindex

View GitHub Profile
//Disabiilitare tutti gli aggiornamenti
define( 'WP_AUTO_UPDATE_CORE', false );
//Disabiilitare aggiornamenti plugin automatici
add_filter( 'auto_update_plugin', '__return_false' );
//Disabiilitare aggiornamenti temi automatici
add_filter( 'auto_update_theme', '__return_false' );
@seoindex
seoindex / add_coupon.php
Created January 12, 2017 11:30
Woocommerce - Applicare sconto in modo automatico
add_action( 'woocommerce_before_cart', 'apply_matched_coupons' ); function apply_matched_coupons() { global $woocommerce; $coupon_code = '10percento'; // titolo del coupon if ( $woocommerce->cart->has_discount( $coupon_code ) ) return; if ( $woocommerce->cart->cart_contents_total >= 500 ) { // valore minimo del carrello $woocommerce->cart->add_discount( $coupon_code ); $woocommerce->show_messages(); } }
@seoindex
seoindex / check_if_product.php
Last active January 12, 2017 11:29
Woocommerce - Applicare sconto se è presente un prodotto specifico nel carrello
function check($product_id) {
global $woocommerce;
 
foreach($woocommerce->cart->get_cart() as $key => $val ) {
$_product = $val['data'];
 
if($product_id == $_product->id ) {
return true;
}
}
@seoindex
seoindex / menu-cart-woocommerce.php
Last active January 10, 2017 09:52
Aggiungere carrello WooCommerce nel menu di wordpress
/**
* Aggiungere l'icona del carrello, numero degli elementi ed il costo totale nel menu
*/
add_filter('wp_nav_menu_items','sk_wcmenucart', 10, 2);
function sk_wcmenucart($menu, $args) {
if ( !in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) || 'primary' !== $args->theme_location )
return $menu;
ob_start();
@seoindex
seoindex / footer.php
Created January 5, 2017 11:13
Aggiungere link diretto alla pagina di login nel footer del vostro tema
@seoindex
seoindex / cart.php
Created January 4, 2017 10:17
Modificare il testo di default del box coupon in woocommerce
<?php
/**
* Cart Page
*
* This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@seoindex
seoindex / functions.php
Created January 4, 2017 09:52
Nascondere un menu dalla sidebar admin per tutti gli utenti tranne che per l'amministratore
function remove_menus(){
remove_menu_page( 'vc-welcome' );
}
add_action( 'admin_menu', 'remove_menus' );
@seoindex
seoindex / email-addresses.php
Created January 4, 2017 08:58
Nascondi indirizzo di fatturazione nella mail di conferma ordine in WooCommerce
<td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
<h3><?php _e( 'Billing address', 'woocommerce' ); ?></h3>
<p class="text"><?php echo $order->get_formatted_billing_address(); ?></p>
</td>
@seoindex
seoindex / style.css
Created January 3, 2017 17:07
Come aumentare la larghezza della casella coupon in woocommerce
.woocommerce table.cart td.actions .coupon {
width: 50%;
}
#page .coupon #coupon_code {
width: auto;
float: left;
}
#page .coupon input.button {
float: left;
}
@seoindex
seoindex / function.php
Last active January 3, 2017 15:05
Cambiare il testo del pulsante "Procedi a PayPal" nella pagina di chechout
add_filter( 'gettext', 'text_paypal_chechout', 20, 3 );
function text_paypal_chechout( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Procedi a PayPal' :
$translated_text = __( 'ACQUISTA ORA', 'woocommerce' );
break;
}
return $translated_text;
}