This file contains hidden or 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
(function($) { | |
$( '.variations_form' ).on( 'woocommerce_variation_has_changed', function( ev ) { | |
$( this ).find( '.variations select' ).each( function( index, el ) { | |
//Get the first select current value | |
var value = $( el ).val(); | |
//Get the original HTML from .data( 'attribute_html' ) and replace it again on the element. | |
$( el ).html( $( el ).data( 'attribute_html' ) ); | |
//Then set the value again | |
$( el ).val( value ); |
This file contains hidden or 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
<?php | |
//Change NIF field priority | |
add_filter( 'woocommerce_nif_field_priority', 'woocommerce_nif_field_priority' ); | |
function woocommerce_nif_field_priority( $priority ) { | |
//Default is 120 | |
return 25; | |
} |
This file contains hidden or 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
<?php | |
add_filter( 'sanitize_file_name', 'my_sanitize_file_name' ); | |
function my_sanitize_file_name( $filename ) { | |
$original_chars = array( | |
'/А/','/Б/','/В/','/Г/', // cyrillic alphabet | |
'/Д/','/Е/','/Ж/','/З/','/И/', | |
'/Й/','/К/','/Л/','/М/','/Н/', | |
'/О/','/П/','/Р/','/С/','/Т/', |
This file contains hidden or 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
<?php | |
//Add this to your (child-)theme functions.php file | |
//Before woocommerce_email_after_order_table 1 and woocommerce_order_details_after_order_table 1, because on the woocommerce_order_barcodes_display_barcode filter we don't have access to the $order object | |
add_action( 'woocommerce_email_after_order_table', 'custom_prevent_barcode', -1, 1 ); | |
add_action( 'woocommerce_order_details_after_order_table', 'custom_prevent_barcode', -1, 1 ); | |
function custom_prevent_barcode( $order ) { | |
$allowed_statuses = array( | |
'processing', |
This file contains hidden or 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
<?php | |
add_action( 'wp_enqueue_scripts', 'my_remove_unnecessary_scripts_and_styles', PHP_INT_MAX ); | |
function my_remove_unnecessary_scripts_and_styles() { | |
//Remove Mapbox styles and scripts | |
global $post; | |
if ( ! ( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'wp_mapbox_gl_js' ) ) ) { | |
wp_dequeue_style( 'mapbox_gl_js_css' ); | |
wp_dequeue_style( 'mapbox_gl_js_geocoder_css' ); | |
wp_dequeue_style( 'mapbox_gl_js_directions_css' ); | |
wp_dequeue_style( 'wp-mapbox-gl-js' ); |
This file contains hidden or 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
<?php | |
/* Hire me at webdados.pt for more WooCommerce magic */ | |
//The function that determines if the shop is closed or not | |
function custom_shop_closed() { | |
//Week days closed - ISO-8601 numeric representation of the day of the week - 1 (for Monday) through 7 (for Sunday) | |
$week_days_closed = array( 5, 6 ); //Fridays and Saturdays | |
//Hours closed | |
$min_hour_close = '07:00'; |
This file contains hidden or 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
<?php | |
//You need this plugin: https://www.webdados.pt/wordpress/plugins/dpd-portugal-para-woocommerce-wordpress/ | |
//Monitor the result (success) and do whatver you want with it - Needs to be set before running it | |
add_action( 'woo_dpd_portugal_requested_pickup', function( $pickup_request ) { | |
var_dump( $pickup_request ); //You should email it, or log it, or... whatever | |
} ); | |
//Monitor the result (error) and do whatver you want with it - Needs to be set before running it |
This file contains hidden or 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
<?php | |
add_filter( 'invoicexpress_woocommerce_automatic_invoice_possible_status', function( $statuses ) { | |
$statuses[] = 'wc-picking'; | |
$statuses[] = 'wc-another-one-bites-the-dust'; | |
return $statuses; | |
} ); |
This file contains hidden or 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
<?php | |
add_filter( 'woocommerce_product_add_to_cart_text', 'my_woocommerce_product_add_to_cart_text', 10, 2 ); | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'my_woocommerce_product_add_to_cart_text', 10, 2 ); | |
function my_woocommerce_product_add_to_cart_text( $text, $product ) { | |
if ( $product->is_on_backorder() ) { | |
return 'Reservar'; | |
} | |
return $text; | |
} |