Skip to content

Instantly share code, notes, and snippets.

View tamarazuk's full-sized avatar
👩‍💻

Tamara Zuk tamarazuk

👩‍💻
View GitHub Profile
@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 / 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'] );
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-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 );
@tamarazuk
tamarazuk / wc-csv-export-item-price.php
Created April 2, 2015 22:26
Customer Order CSV Export: Show the product price in the Default export formats
/**
* Add the product price to the individual line item entry
*
* @param array $line_item the original line item data
* @param array $item WC order item data
* @param WC_Product $product the product
* @return string
*/
function wc_csv_export_order_line_item_price( $line_item, $item, $product ) {
@tamarazuk
tamarazuk / wc-xml-export-filename-merge-variables.php
Last active August 29, 2015 14:18
Customer/Order XML Export: Adding a new merge variable for the order export file name.
/**
* Add support for %%payment_method%% merge variable to XML export file names
*
* @param string $post_replace_filename the post replace filename
* @param string $post_replace_filename the pre replace filename
* @param array $order_ids the order ids
* @return string
*/
function wc_xml_export_suite_file_name_payment_method( $post_replace_filename, $pre_replace_filename, $order_ids ) {
@tamarazuk
tamarazuk / wc-gateway-mollie-payment-gateway-fees-compat.php
Last active August 29, 2015 14:18
Mollie Payment Gateway: Add compatibility for Payment Gateway Based Fees
<?php
/**
* Plugin Name: WooCommerce Mollie Gateway - Additional Fees Compatibility
* Plugin URI: http://www.woothemes.com/products/ideal-mollie/
* Description: Adds support for Payment Gateway Based Fees. Adds fees for each Mollie payment gateway based on fees listed at https://www.mollie.com/en/pricing
* Author: SkyVerge
* Author URI: http://www.skyverge.com
* Version: 1.0.0
*
* Copyright: (c) 2015 SkyVerge, Inc. ([email protected])
@tamarazuk
tamarazuk / wc-order-status-manager-order-is-editable.php
Last active February 15, 2016 01:03
WooCommerce Order Status Manager: Allow orders with custom statuses to be edited
function sv_wc_order_status_manager_order_is_editable( $editable, $order ) {
// list the slugs of all order statuses that should be editable.
// Note 'pending', 'on-hold', 'auto-draft' are editable by default
$editable_custom_statuses = array( 'packaging', 'awaiting-shipment' );
if ( in_array( $order->get_status(), $editable_custom_statuses ) ) {
$editable = true;
}
<?php
// change CSV delimiter to a semi-colon (;)
function wc_csv_export_modify_delimiter() {
return ';';
}
add_filter( 'wc_customer_order_csv_export_delimiter', 'wc_csv_export_modify_delimiter' );
// change CSV enclosure to a pipe (|)
function wc_csv_export_modify_enclosure() {
return '|';
@tamarazuk
tamarazuk / wc-address-validation-smartystreets-badge-fix.php
Last active August 29, 2015 14:12
WooCommerce Address Validation SmartyStreets badge fix
<?php
function wc_address_validation_smartystreets_badge_fix() {
wc_enqueue_js( '
$( "body" ).on( "wc_address_validation_fields_mapped", function() {
$.each( [ "billing", "shipping" ], function( index, addressType ) {
var fields = $( "#" + addressType + "_address_1, #" + addressType + "_address_2, #" + addressType + "_city, #" + addressType + "_state, #" + addressType + "_postcode, #" + addressType + "_country" );
fields.on( "visibility", function() {