Skip to content

Instantly share code, notes, and snippets.

@trey8611
trey8611 / WooCommerce-export-country-and-state.php
Created September 14, 2020 17:25
WP All Export - WooCommerce Orders - Convert country code or state code to full names.
<?php
// Use these on the Order ID element in an export.
function my_get_country( $order_id ) {
$order = wc_get_order( $order_id );
if ( empty( $order ) ) return;
$country = $order->get_shipping_country();
$countries = WC()->countries->countries;
if ( array_key_exists( $country, $countries ) ) {
@Marigno
Marigno / link-products-without-sku-to-orders.md
Last active March 7, 2022 20:32
Link products without SKU to orders
@trey8611
trey8611 / Import Types.md
Last active July 26, 2021 12:56 — forked from KittenCodes/Import Types.md
WP All Import - A description of different import types "New Items" and "Existing Items"

A description of import types

  • New Items Import -

This is primarily used to create and manage products. It keeps internal track of the products that it imports, which means that it can later update/create/delete products as they're changed/added/removed in your import file (see: http://www.wpallimport.com/documentation/recurring/update-import). It's also the only import type that can add/remove variations for variable products.

One limitation of new items imports is that cannot detect/update products that it didn't previously create. If you need to use a "New Items" import with a file that contains existing products, you can use WP All Import's API to prevent duplicates from being imported: https://www.wpallimport.com/documentation/developers/code-snippets/#do-not-create-products-with-duplicate-sku.

  • Existing Items Import -
@trey8611
trey8611 / import_product_model_file.md
Last active September 21, 2024 21:02
WP All Import & WooCommerce Add-On - How to import PRODUCT / MODEL product files.

Importing PRODUCT / MODEL files

If you're trying to import a file that has this sort of structure:

data in csv

You're going to run into a few issues:

  1. Variations do not have title/content data.
  2. Variations do not have prices or images.
@trey8611
trey8611 / query_cyrillic_attribute_values.md
Last active April 17, 2024 17:23
WP All Import - use XPath Query based on Cyrillic attribute value

XPath doesn't allow you to make queries with Cyrillic symbols unless you disable XML pre-processing by adding this code in your child themes functions.php file (or in a plugin like Code Snippets: https://wordpress.org/plugins/code-snippets/):

function wpai_is_xml_preprocess_enabled( $is_enabled ) {
	return false;
}
add_filter( 'is_xml_preprocess_enabled', 'wpai_is_xml_preprocess_enabled', 10, 1 );

Once that code is in place, upload your file to an import and queries like this will be possible: