<?php
function dp_change_name_to_sku ( $args, $order ) {
$$args_keys = array_keys($args);
$i = 0;
// Iterating through order items
foreach( $order->get_items() as $item_id => $item_product ){
$product_id = $item_product->get_product_id();
$i++; // updating count.
if( ! empty($args["item_name_$i"]) ){
// getting sku of product
$args["item_name_$i"] = get_post_meta($product_id, '_sku', true);
}
}
return $args;
}
add_filter('woocommerce_paypal_args', 'dp_change_name_to_sku', 10, 2 );
?>
Was this article helpful?