Skip to content

Instantly share code, notes, and snippets.

View tamarazuk's full-sized avatar
👩‍💻

Tamara Zuk tamarazuk

👩‍💻
View GitHub Profile
@tamarazuk
tamarazuk / wc-checkout-add-ons-wpml-multi-currency.php
Last active August 29, 2019 01:42
WooCommerce Checkout Add-ons: WPML mult-currency support
function wc_checkout_add_ons_wpml_multi_currency_support( $adjustment ) {
return apply_filters( 'wcml_raw_price_amount', $adjustment );
}
add_filter( 'woocommerce_checkout_add_on_get_adjustment', 'wc_checkout_add_ons_wpml_multi_currency_support', 100 );
add_filter( 'wc_checkout_add_ons_add_on_option_cost', 'wc_checkout_add_ons_wpml_multi_currency_support', 100 );
function sv_add_weight_to_csv_export_import_format( $order_data, $order ) {
$count = 1;
// add line items
foreach ( $order->get_items() as $item ) {
$product = $order->get_product_from_item( $item );
if ( ! is_object( $product ) ) {
@tamarazuk
tamarazuk / wc-csv-export-line-item-meta-delimiter.php
Created May 20, 2015 20:52
Customer/Order CSV Export - Replace line item meta delimiter with a semi-colon
function sv_wc_csv_export_replace_line_item_delimiter( $order_data ) {
// temporarily replace the line item delimiter
$order_data['line_items'] = str_replace( ';', '>>>', $order_data['line_items'] );
// replace the line item meta delimiter with ;
$order_data['line_items'] = str_replace( '|', ';', $order_data['line_items'] );
// replace the temporary line item delimiter with |
$order_data['line_items'] = str_replace( '>>>', '|', $order_data['line_items'] );
@tamarazuk
tamarazuk / wc-shipwire-custom-shipping-method.php
Created May 22, 2015 00:33
WooCommerce Shipwire - Set a custom shipping method
function wc_shipwire_set_custom_shipping_method( $fields, $order_id ) {
$fields['shipping_code'] = 'GD';
$order = wc_get_order( $order_id );
foreach ( $order->get_shipping_methods() as $method ) {
if ( '2-Day Shipping' == $method['name'] ) {
$fields['shipping_code'] = '2D';
break;
@tamarazuk
tamarazuk / mpc.php
Created June 8, 2015 17:56
Measurement Price Calculator: Set step increment for user-defined measurements
function sv_wc_measurement_price_calculator_amount_needed() {
wc_enqueue_js( '
$( "input.amount_needed" ).attr( { "step" : "0.1", "type" : "number" } );
' );
}
add_action( 'wp_enqueue_scripts', 'sv_wc_measurement_price_calculator_amount_needed' );
@tamarazuk
tamarazuk / wc-tab-manager-conditionally-hide-tab.php
Created June 16, 2015 23:15
WooCommerce Tab Manager - Conditionally hide tab
<?php
function wc_tab_manager_product_tabs_hide_books_tab( $tabs ) {
global $product;
// + check if we are on the product page before removing the tab so that the
// tab still displays in the admin
// + change some_condition() to a function/variable which returns true if the
// product should be displayed
// + "unique-tab-name" is uniquely generated by Tab Manager and can be found by
// inspecting the source on a product page and finding the HTML which outputs
@tamarazuk
tamarazuk / skyverge-snippets.php
Created June 18, 2015 03:33
WooCommerce Shipwire - Remove notices
function sv_wc_shipwire_remove_notice( $message ) {
$shipwire_notices = array(
'Please enter your country to see available shipping rates.',
'Please enter your ZIP Code to see available shipping rates.',
);
if ( in_array( $message, $shipwire_notices ) ) {
$message = '';
}
@tamarazuk
tamarazuk / sv-wc-measurement-price-calculator-translate-labels-example.php
Last active April 30, 2021 14:20
WooCommerce Measurement Price Calculator - Translate labels
<?php // only copy this line if needed
function sv_mpc_measurement_label( $label ) {
if ( 'fr_FR' === get_locale() ) {
$label = str_replace( 'Required Width', 'Largeur requise', $label );
$label = str_replace( 'Width', 'Largeur', $label );
}
return $label;
@tamarazuk
tamarazuk / social-login.php
Created September 15, 2015 21:16
WooCommerce Social Login - Request user location from Facebook
function sv_wc_social_login_facebook_user_location( $config ) {
$config['scope'] = $config['scope'] . ', user_location';
return $config;
}
add_filter( 'wc_social_login_facebook_opauth_config', 'sv_wc_social_login_facebook_user_location' );
@tamarazuk
tamarazuk / mpc.php
Last active October 20, 2015 01:45
WPML WooCommerce Multilingual compatability with Measurement Price Calculator
<?php // only copy this line if needed
// WPML WooCommerce Multilingual compatability with Measurement Price Calculator
function sv_wc_mpc_woocommerce_multilingual_duplicate_exception( $exclude, $cart_item ) {
if ( isset( $cart_item[ 'pricing_item_meta_data' ] ) ) {
$exclude = true;
}
return $exclude;