Below is a PHP function you can use in WP All Import to enable custom text mapping anywhere in your import. You would use it in your import field like this:
[my_map({field[1]})]
Where "{field[1]}" would be the correct field name from your file.
<?php | |
add_filter( 'woocommerce_payment_complete_order_status', 'wmg_auto_complete_virtual_orders', 10, 3 ); | |
/** | |
* Automatically complete orders with only virtual products | |
* | |
* @param string $payment_complete_status Order status used after an order payment is received | |
* @param int $order_id ID of the order being processed | |
* @param WC_Order $order Order object being processed |
Here are some example WP All Import [IF] statements. The criteria for an IF statment is written in XPath 1.0 syntax and can use XPath functions. Although powerful, XPath syntax can be quite complex. In many cases it might be easier to use a PHP function as shown here.
Note: The [ELSE]<something>
part is optional
[IF({price[.=0]})]Zero[ELSE]Not Zero[ENDIF]
add_filter( 'woocommerce_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 2 ); | |
function virtual_order_payment_complete_order_status( $order_status, $order_id ) { | |
$order = new WC_Order( $order_id ); | |
if ( 'processing' == $order_status && | |
( 'on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status ) ) { | |
$virtual_order = null; | |
if ( count( $order->get_items() ) > 0 ) { | |
foreach( $order->get_items() as $item ) { | |
if ( 'line_item' == $item['type'] ) { | |
$_product = $order->get_product_from_item( $item ); |
/** | |
* Auto Complete all WooCommerce orders. | |
* Add to theme functions.php file | |
*/ | |
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' ); | |
function custom_woocommerce_auto_complete_order( $order_id ) { | |
global $woocommerce; | |
if ( !$order_id ) |