Skip to content

Instantly share code, notes, and snippets.

View tamarazuk's full-sized avatar
👩‍💻

Tamara Zuk tamarazuk

👩‍💻
View GitHub Profile
@tamarazuk
tamarazuk / woocommerce-csv-export-separate-item-meta.php
Last active August 31, 2018 04:42
Customer/Order CSV Export: Separate item meta into multiple columns in the Default – One Row per Item format
<?php // only copy this line if needed
/**
* The use of this snippet requires at least WooCommerce 3.2
*/
/**
* Alter the column headers for the orders CSV to split item_meta into separate columns
*
* Note that this change is only applied to the Default - One Row per Item format
@tamarazuk
tamarazuk / wc-nested-category-layout-category-title-remove-parent.php
Last active July 28, 2020 13:31
WooCommerce Nested Category Layout - Remove parent category name from category title
<?php
add_filter( 'wc_nested_category_layout_category_title_html', 'wc_nested_category_layout_category_title_html', 10, 3 );
function wc_nested_category_layout_category_title_html( $title, $categories, $term ) {
$category = $categories[ count( $categories ) - 1 ];
$url = esc_attr( get_term_link( $category ) );
$link = '<a href="' . $url . '">' . wptexturize( $category->name ) . '</a>';
return sprintf( '<h2 class="wc-nested-category-layout-category-title">%s</h2>', $link );
@tamarazuk
tamarazuk / wc-address-validation-move-postcode-lookup.php
Created November 20, 2014 22:57
WooCommerce Address Validation: Move postcode lookup fields to the top of billing and shipping fields rather than keeping them below the country field.
<?php
function wc_address_validation_move_postcode_lookup() {
wc_enqueue_js( '
( function() {
var $billingLookup = $( "#wc_address_validation_postcode_lookup_billing" );
var $shippingLookup = $( "#wc_address_validation_postcode_lookup_shipping" );
$( "div.woocommerce-billing-fields").find( "h3" ).after( $billingLookup );
@tamarazuk
tamarazuk / wc-gateway-mollie-reorder-gatweays.php
Last active August 29, 2015 14:10
WooCommerce Mollie Gateway - Reorder Mollie payment options
<?php
function wc_mollie_reorder_gateways( $gateways ) {
$gateway_order = array(
// Rearrange these payment options into the order you wish
'WC_Gateway_Mollie_iDEAL',
'WC_Gateway_Mollie_CreditCard',
'WC_Gateway_Mollie_MisterCash',
@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() {
<?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-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;
}
@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-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-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 ) {