This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Global site tag (gtag.js) - Google Analytics --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-X"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'UA-XXXXXXXX-X'); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* HABILITAR CANTIDAD MÍNIMA DE PEDIDO | |
*/ | |
function woo_minimum_order_amount() { | |
$minimum = 10; //Establecer importe mínimo de compra | |
if ( WC()->cart->total < $minimum ) { | |
if( is_cart() ) { | |
wc_print_notice( | |
sprintf( 'Debes realizar un pedido mínimo de %s para finalizar tu compra.' , // Personalizar | |
wc_price( $minimum ), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* DESHABILITAR PESTAÑAS DE LA FICHA DE PRODUCTO | |
*/ | |
function woo_remove_product_tab($tabs) { | |
unset( $tabs['description'] ); // Eliminar la pestaña de Descripción | |
unset( $tabs['reviews'] ); // Eliminar la pestaña de Valoraciones | |
unset( $tabs['additional_information'] ); // Eliminar la pestaña de Información Adicional | |
return $tabs; | |
} | |
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tab', 98); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* DESHABILITAR CAMPOS DEL FORMULARIO DE PAGO | |
*/ | |
function woo_custom_override_checkout_fields( $fields ) { | |
unset ($fields['billing']['billing_first_name']); // Eliminar el campo Nombre | |
unset ($fields['billing']['billing_last_name']); // Eliminar el campo Apellidos | |
unset ($fields['billing']['billing_company']); // Eliminar el campo Empresa | |
unset ($fields['billing']['billing_address_1']); // Eliminar el campo Dirección 1 | |
unset ($fields['billing']['billing_address_2']); // Eliminar el campo Dirección 2 | |
unset ($fields['billing']['billing_postcode']); // Eliminar el campo Código Postal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* REDIRIGIR A FINALIZAR COMPRA TRAS AÑADIR PRODUCTO | |
*/ | |
function woo_redirect_to_checkout() { | |
global $woocommerce; | |
$checkout_url = $woocommerce->cart->get_checkout_url(); | |
return $checkout_url; | |
} | |
add_filter ('add_to_cart_redirect', 'woo_redirect_to_checkout'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* REALIZAR SEGUIMIENTO DE CONVERSIONES DE FACEBOOK | |
*/ | |
function woo_facebook_pixel_tracking( $order_id ) { | |
$order = new WC_Order( $order_id ); | |
$order_total = $order->get_total(); | |
?> | |
<script>fbq('track', 'Purchase', {'value':'<?php echo $order_total ?>','currency':'EUR'});</script> | |
<?php | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* FINALIZAR LOS PEDIDOS AUTOMÁTICAMENTE | |
*/ | |
function woo_auto_complete_order( $order_id ) { | |
global $woocommerce; | |
if ( ! $order_id ) { return; } | |
$order = new WC_Order( $order_id ); | |
$order->update_status( 'completed' ); | |
} | |
add_action( 'woocommerce_thankyou', 'woo_auto_complete_order' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* DESHABILITAR PASARELAS DE PAGO EN DETERMINADOS PAÍSES | |
*/ | |
function woo_countries_gateways( $available_gateways ) { | |
global $woocommerce; | |
$countries = array( 'FR', 'IT', 'DE' ); // Listado de países ISO excluidos | |
$payment_gateway = 'cod'; // Pasarela de pago deshabilitada | |
if ( isset( $available_gateways[ $payment_gateway ] ) && in_array( $woocommerce->customer->get_country(), $countries ) ) { | |
unset( $available_gateways[ $payment_gateway ] ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AÑADIR CAMPO NIF/CIF EN EL FORMULARIO DE PAGO | |
*/ | |
function woo_custom_field_checkout($checkout) { | |
echo '<div id="additional_checkout_field">'; | |
woocommerce_form_field( 'nif', array( // Identificador del campo | |
'type' => 'text', | |
'class' => array('my-field-class form-row-wide'), | |
'required' => true, // ¿El campo es obligatorio 'true' o 'false'? | |
'label' => __('NIF / CIF'), // Nombre del campo |
NewerOlder