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 March 27, 2018 15:18
Make all product images in WooCommerce 3.3 square and cropped
function woo_custom_single_image_size ( $size ) {
$size['height'] = $size['width'];
$size['crop'] = 1;
return $size;
}
add_filter('woocommerce_get_image_size_single', 'woo_custom_single_image_size', 50, 1);
add_filter('woocommerce_get_image_size_shop_single', 'woo_custom_single_image_size', 50, 1);
add_filter('woocommerce_get_image_size_thumbnail', 'woo_custom_single_image_size', 50, 1);
add_filter('woocommerce_get_image_size_gallery_thumbnail', 'woo_custom_single_image_size', 50, 1);
@madeincosmos
madeincosmos / functions.php
Created March 26, 2018 14:07
WooCommerce Google Product Feed - allow prepopulating the Condition field
function custom_gpf_can_prepopulate_condition ( $feedData ) {
$feedData['condition']['can_prepopulate'] = true;
return $feedData;
}
add_filter( 'woocommerce_gpf_all_product_fields', 'custom_gpf_can_prepopulate_condition', 10, 1);
@madeincosmos
madeincosmos / functions.php
Created February 21, 2018 15:00
Change 'Description' tab title on the product page
function custom_description_tab_name ( $name ) {
return 'Ingredients';
}
add_filter( 'woocommerce_product_description_heading', 'custom_description_tab_name', 10 );
add_filter( 'woocommerce_product_description_tab_title', 'custom_description_tab_name', 10 );
@madeincosmos
madeincosmos / wc-fix-stripe-tokens.php
Created February 13, 2018 15:47
Fix outdated Stripe tokens in WooCommerce
<?php
/*
* Plugin Name: Fix customer tokens for WooCommerce Stripe
* Plugin URI:
* Description: Fixes outdated customer tokens saved on customers registered before mid 2014
* Author: Maria Gorska
* Author URI:
* License: GPLv3
* Version: 0.1.0
* Version: 0.1.0
@madeincosmos
madeincosmos / functions.php
Created January 17, 2018 10:03
Add Product SKU on shop and category pages
function woocommerce_after_shop_loop_item_title_short_description() {
global $product;
if ( ! $product->get_sku() ) return;
?> <div itemprop="description">
<?php echo apply_filters( 'woocommerce_short_description', $product->get_sku() ) ?> </div>
<?php
}
add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_after_shop_loop_item_title_short_description', 5);
@madeincosmos
madeincosmos / functions.php
Created January 10, 2018 10:32
Defer sending order emails in WooCommerce
add_filter( 'woocommerce_defer_transactional_emails', '__return_true' );
@madeincosmos
madeincosmos / functions.php
Created December 8, 2017 08:08
Change the Add to cart button on shop pages into a Read More link
add_action('init','remove_loop_button');
function remove_loop_button(){
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
}
add_action('woocommerce_after_shop_loop_item','replace_add_to_cart');
function replace_add_to_cart() {
global $product;
@madeincosmos
madeincosmos / functions.php
Created December 1, 2017 09:51
Automatically approve registered vendors
function automaticallyApproveRegisteredVendors ( $vendorData ) {
$vendorData['role'] = 'wc_product_vendors_admin_vendor';
return $vendorData;
}
add_filter( 'wcpv_registration_default_user_data', 'automaticallyApproveRegisteredVendors', 10, 1);
@madeincosmos
madeincosmos / functions.php
Created December 1, 2017 07:26
Add Google Optimizer code in WooCommerce Google Analytics
function addTrackingCodeinGAPlugin ( $requireCode ) {
$requireCode .= "ga('require', 'GTM-KZ35PPF');"
return $requireCode;
}
add_filter( 'woocommerce_ga_snippet_require', 'addTrackingCodeinGAPlugin', 10, 1 );
@madeincosmos
madeincosmos / functions.php
Last active October 24, 2017 14:52
Disable autofocus on the checkout page
add_filter( 'woocommerce_form_field_args', 'custom_form_field_args', 30, 3 );
function custom_form_field_args( $args, $key, $value ) {
$args['autofocus'] = '';
return $args;
};