Skip to content

Instantly share code, notes, and snippets.

View madeincosmos's full-sized avatar

Maria Górska-Piszek madeincosmos

View GitHub Profile
@madeincosmos
madeincosmos / functions.php
Created August 19, 2019 13:04
Send billing address to PayPal even when shipping is disabled
/* Send billing address to PayPal even when shipping is disabled (2278024-zen) */
add_filter( 'woocommerce_paypal_args', 'force_send_billing_address_to_paypal', 10 );
function force_send_billing_address_to_paypal ( $args ) {
$args[ 'no_shipping' ] = 0;
return $args;
}
@madeincosmos
madeincosmos / functions.php
Created August 6, 2019 08:40
Scale WooCommerce gallery thumbnails to 180x180 px
function woo_custom_single_image_size ( $size ) {
$size['height'] = 180;
$size['width'] = 180;
$size['crop'] = 1;
return $size;
}
add_filter('woocommerce_get_image_size_gallery_thumbnail', 'woo_custom_single_image_size', 50, 1);
@madeincosmos
madeincosmos / functions.php
Last active May 29, 2019 13:15
Add `F-` in front of French postcodes in WooCommerce
/* This will "normalize" the postcode entered by the customer, if the country selected is France.
* If the customer entered their postcode as a 5-digit number, it will add `F-` in the front.
* If they already entered `F-` the post code will stay as it is.
*/
add_filter( 'woocommerce_format_postcode', 'custom_add_post_code_format_for_france', 10, 2 );
function custom_add_post_code_format_for_france( $postcode, $country ){
$postcode = wc_normalize_postcode( $postcode );
switch ( $country ) {
@madeincosmos
madeincosmos / functions.php
Created May 23, 2019 10:11
Add customer username and ID to WooCommerce emails
add_filter( 'woocommerce_email_customer_details_fields', 'add_user_id_to_woocommerce_emails', 10, 3);
function add_user_id_to_woocommerce_emails( $fields, $sent_to_admin, $order ) {
$user_id = $order->get_customer_id();
$user_info = get_userdata( $user_id );
$fields['user_id'] = array(
'label' => __( 'User ID', 'woocommerce' ),
'value' => $user_id
);
@madeincosmos
madeincosmos / functions.php
Created March 12, 2019 19:20
Add PayPal Pro support for custom countries
function custom_add_paypal_supported_cc_for_bolivia ( $data ) {
$data['BO'] = array (
'Visa' => 'Visa',
'MasterCard' => 'MasterCard',
);
return $data;
}
add_filter ( 'woocommerce_paypal_pro_available_card_types', 'custom_add_paypal_supported_cc_for_bolivia' );
@madeincosmos
madeincosmos / functions.php
Created December 31, 2018 11:13
Change WebSite schema in WooCommerce
function my_custom_structured_data( $markup ) {
$markup['name'] = 'Website name';
return $markup;
}
add_filter( 'woocommerce_structured_data_website', 'my_custom_structured_data', 10, 1);
@madeincosmos
madeincosmos / functions.php
Last active December 3, 2018 13:27
Change header image size in Storefront
function woo_custom_storefront_header_size( $args ) {
$args['height'] = 1000;
return $args;
}
add_filter( 'storefront_custom_header_args', 'woo_custom_storefront_header_size' );
@madeincosmos
madeincosmos / functions.php
Created August 28, 2018 17:31
Change Apple Pay language to English
function change_apple_pay_button_language( $stripe_params ){
return 'en';
}
add_filter( 'wc_stripe_payment_request_button_locale', 'change_apple_pay_button_language' );
@madeincosmos
madeincosmos / functions.php
Created August 28, 2018 17:28
Remove 'via WooCommerce' from Apple Pay
function remove_apple_pay_label_suffix( $stripe_params ){
return '';
}
add_filter( 'wc_stripe_payment_request_total_label_suffix', 'remove_apple_pay_label_suffix' );
@madeincosmos
madeincosmos / functions.php
Last active July 3, 2018 14:46
Disable removing inactive bookings from cart
function custom_disable_removing_inactive_bookings ( $time ) {
return 0;
}
add_filter( 'woocommerce_bookings_remove_inactive_cart_time', 'custom_disable_removing_inactive_bookings', 10 );
add_filter( 'woocommerce_bookings_failed_order_expire_scheduled_time_stamp', 'custom_disable_removing_inactive_bookings', 10 );