Skip to content

Instantly share code, notes, and snippets.

View tamarazuk's full-sized avatar
👩‍💻

Tamara Zuk tamarazuk

👩‍💻
View GitHub Profile
@tamarazuk
tamarazuk / wc-cart-notices-translate-messages-with-wpml.php
Last active March 12, 2021 06:38
WooCommerce Cart Notices: Translate Messages using WPML
<?php // only copy this line if needed
/**
* Register Cart Notices texts for translation with WPML when the messages are first created/updated
*/
add_filter( 'wc_cart_notices_update_fields', function( $fields ) {
if ( isset( $fields['name'] ) ) {
$slug = sanitize_title( $fields['name'] );
@tamarazuk
tamarazuk / sv_wc_charge_order_on_order_complete.php
Created September 13, 2020 05:21
Charge a WooCommerce pre-order when the associated order is set to Completed status
<?php // only copy this line if needed
/**
* Charge a WooCommerce pre-order when the associated order is set to Completed status
*
* @param int $order_id
* @param \WC_Order $order
*/
function sv_wc_charge_order_on_order_complete( $order_id, $order ) {
@tamarazuk
tamarazuk / snippet-sv_facebook_for_wc_basel_theme_add_filter_for_add_to_cart_fragments.php
Last active July 4, 2020 02:50 — forked from deivamagalhaes/snippet.php
Facebook for WooCommerce: Track AddToCart event on Basel theme
<?php // only copy this line if needed
function sv_facebook_for_wc_basel_theme_add_filter_for_add_to_cart_fragments() {
// only make changes as long as Facebook for WooCommerce is installed
if ( function_exists( 'facebook_for_woocommerce' ) ) {
$events_tracker = facebook_for_woocommerce()->get_integration()->events_tracker;
$events_tracker->add_filter_for_conditional_add_to_cart_fragment();
}
@tamarazuk
tamarazuk / facebook-for-wc-disable-tracking-admin-purchases.php
Created June 12, 2020 02:59
facebook-for-wc-disable-tracking-admin-purchases.php
<?php // only copy this line if needed
add_action( 'init', function() {
if ( current_user_can( 'manage_options' ) && function_exists( 'facebook_for_woocommerce' ) && isset( facebook_for_woocommerce()->get_integration()->events_tracker ) ) {
$event_tracker = facebook_for_woocommerce()->get_integration()->events_tracker;
remove_action( 'woocommerce_thankyou', [ $event_tracker, 'inject_purchase_event' ], 40 );
remove_action( 'woocommerce_payment_complete', [ $event_tracker, 'inject_purchase_event' ], 40 );
@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
*
@tamarazuk
tamarazuk / wc-product-vendors-customer-order-csv-export-compatibility.php
Last active February 18, 2018 14:03 — forked from roykho/gist:b5e6849adacd9970fc6f
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-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 / 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 / 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 / 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_' ) ) {