Skip to content

Instantly share code, notes, and snippets.

View tamarazuk's full-sized avatar
👩‍💻

Tamara Zuk tamarazuk

👩‍💻
View GitHub Profile
@tamarazuk
tamarazuk / pdf-product-vouchers.php
Created October 20, 2015 06:33
WooCommerce Multilingual - Compatability with PDF Product Vouchers
<?php //only copy this line if needed
// WPML WooCommerce Multilingual compatability with PDF Product Vouchers
function sv_wc_pdf_product_vouchers_wc_multilingual_duplicate_exception( $exclude, $cart_item ) {
if ( isset( $cart_item[ 'voucher_id' ] ) ) {
$exclude = true;
}
return $exclude;
@tamarazuk
tamarazuk / wc-csv-export-auto-export-subs-renewals.php
Created January 6, 2016 00:56
WooCommerce Customer/Order CSV Export - Auto-export only orders with subscriptions or renewals
<?php // only copy this line if needed
function sv_wc_customer_order_csv_auto_export_subscriptions_renewals_only( $order_ids ) {
if ( defined( 'DOING_CRON' ) && DOING_CRON && function_exists( 'wcs_order_contains_subscription' ) ) {
$subscriptions = $renewals = array();
$subscriptions = array_filter( $order_ids, 'wcs_order_contains_subscription' );
$renewals = array_filter( $order_ids, 'wcs_order_contains_renewal' );
@tamarazuk
tamarazuk / wc-csv-import-disable-customer-change-emails.php
Last active March 31, 2020 03:55
WooCommerce CSV Import - Disable WP user email/password change emails
<?php // only copy this line if needed
add_filter( 'send_password_change_email', '__return_false' );
add_filter( 'send_email_change_email', '__return_false' );
@tamarazuk
tamarazuk / social-login.php
Created January 22, 2016 06:28
WooCommerce Social Login: Customize user date
<?php // only copy this line if needed
function sv_wc_social_login_new_user_data_add_filters() {
foreach ( array_keys( wc_social_login()->get_available_providers() ) as $provider ) {
add_filter( 'wc_social_login_' . $provider . '_new_user_data', 'sv_wc_social_login_new_user_data' );
}
}
add_action( 'init', 'sv_wc_social_login_new_user_data_add_filters' );
@tamarazuk
tamarazuk / wc-admin-custom-order-fields-wc-api.php
Last active March 31, 2018 11:32
WooCommerce Admin Custom Order Fields - Allow custom order fields to be accessed by the WooCommerce REST API
<?php // only copy this line if needed
function sv_wc_api_allow_acof_protected_meta() {
add_filter( 'is_protected_meta', 'sv_wc_acof_is_protected_meta', 10, 2 );
}
add_action( 'woocommerce_api_loaded', 'sv_wc_api_allow_acof_protected_meta' );
function sv_wc_acof_is_protected_meta( $protected, $meta_key ) {
if ( 0 === strpos( $meta_key, '_wc_acof_' ) ) {
@tamarazuk
tamarazuk / wc-gateway-auth-net-cim-payment-form-tokenization-forced.php
Created February 10, 2016 23:17
WooCommerce Authorize.net CIM: Force tokenization in the Payment Form
<?php // only copy this line if needed
add_filter( 'wc_authorize_net_cim_credit_card_payment_form_tokenization_forced', '__return_true' );
@tamarazuk
tamarazuk / sv-wc-google-analytics-pro-utm-nooverride.php
Created May 20, 2016 18:19
WooCommerce Google Analytics Pro - Ensure off-site gateways aren't tracked as referrers
<?php // only copy this line if needed
/**
* Add the utm_nooverride parameter to any return urls. This makes sure Google Adwords doesn't mistake the offsite gateway as the referrer.
*
* @link https://github.com/woothemes/woocommerce-google-analytics-integration/blob/c805bb4c24de235227c2b4b21b179d73bd8a7861/includes/class-wc-google-analytics.php#L506-L522
*
* @param string $return_url WooCommerce Return URL
* @return string URL
*/
@tamarazuk
tamarazuk / sv-wc-csv-export-auto-export-dont-skip-exported.php
Last active April 7, 2020 16:49
WooCommerce Customer/Order/Coupon Export: Export all orders when automatically exporting (don't skip orders with exported status)
<?php // only copy this line if needed
add_filter( 'wc_customer_order_export_auto_export_new_orders_only', '__return_false' );
@tamarazuk
tamarazuk / wc-product-vendors-customer-order-csv-export-compatibility.php
Last active February 18, 2018 14:03
WooCommerce Product Vendors 2.0 - Add columns to WooCommerce Customer/Order CSV Export
<?php // only copy this line if needed
add_filter( 'wc_customer_order_csv_export_order_headers', 'wc_product_vendors_csv_export_integration_add_column_headers' );
add_filter( 'wc_customer_order_csv_export_order_line_item', 'wc_product_vendors_csv_export_integration_modify_line_item', 10, 5 );
add_filter( 'wc_customer_order_csv_export_order_row_one_row_per_item', 'wc_product_vendors_csv_export_integration_add_row_data', 10, 4 );
function wc_product_vendors_csv_export_integration_add_column_headers( $headers ) {
$headers['vendor'] = 'Vendor';
@tamarazuk
tamarazuk / sv-wc-measurement-price-calculator-quantity-pattern-fix.php
Last active July 1, 2020 03:59
WooCommerce Measurement Price Calculator: Redefine the quantity input's pattern to include floating point values to fix the "Please match the requested format" HTML validation error that occurs with the Enfold theme. Please review our guide for adding custom code to WordPress Sites here: https://www.skyverge.com/blog/add-custom-code-to-wordpress/
<?php // only copy this line if needed
/**
* Filter the quantity input's pattern attribute to fix the "Please
* match the requested format" HTML validation error that occurs when using
* WooCommerce Measurement Price Calculator with certain premium themes
*
* @props to mensmaximus {@link https://github.com/mensmaximus} for the
* proposed solution
*