Skip to content

Instantly share code, notes, and snippets.

View woogist's full-sized avatar

WooCommerce.com Documentation woogist

View GitHub Profile
function custom_tracking_code() {
if ( is_product() ) {
?> Add your Product code here <?php
} elseif ( is_cart() ) {
?> Add your Cart code here <?php
} elseif ( is_order_received_page() ) {
?> Add your Thank you code here <?php
}
}
add_action( 'wp_head', 'custom_tracking_code' );
@woogist
woogist / wc_shipment_tracking_add_custom_provider.php
Last active September 22, 2022 02:37
Shipment Tracking: adds custom provider
/**
* wc_shipment_tracking_add_custom_provider
*
* Adds custom provider to shipment tracking or add existing providers to another country.
*
* Change the country name, the provider name, and the URL (it must include the %1$s)
* Add one provider per line
*/
add_filter( 'wc_shipment_tracking_get_providers' , 'wc_shipment_tracking_add_custom_provider' );
add_filter( 'wc_session_expiring', create_function( '', 'return 10;' ) );
add_filter( 'wc_session_expiration', create_function( '', 'return 15;' ) );
add_filter( 'wc_photography_shop_loop_image_html', 'wc_photography_loop_image_link' );
function wc_photography_loop_image_link( $html ) {
global $product;
return preg_replace( '/href="([^"]*)"/', sprintf( 'href="%s"', get_permalink( $product->id ) ), $html );
}
add_filter( 'woocommerce_reports_get_order_report_query', 'wc_custom_limit_query' );
function wc_custom_limit_query( $query ) {
global $wpdb;
$wpdb->query( "SET OPTION SQL_BIG_SELECTS=1" );
return $query;
}
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( 'input[name="addon-90-adventure-dates[check-in]"]' ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( "input[name='addon-90-adventure-dates']" ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
// Check the name of your addon field in the source. Example: addon-7934-test-addon
jQuery( 'input[name="addon-90-adventure-dates[check-in]"]' ).datepicker( {
minDate: 0,
"dateFormat": 'yy-mm-dd'
} );
function jeherve_delete_jetpack_menu() {
if ( ! current_user_can( 'manage_options' ) ) {
remove_menu_page( 'jetpack' );
}
}
add_action ( 'admin_menu', 'jeherve_delete_jetpack_menu', 999 );
add_filter( 'woocommerce_countries_base_postcode', create_function( '', 'return "80903";' ) );
add_filter( 'woocommerce_countries_base_city', create_function( '', 'return "COLORADO SPRINGS";' ) );