$order_items = $order->get_items();
foreach ($order_items as $item_key => $item) {
$product = $item->get_product(); // Get the WC_Product Object
if( $product->is_type( 'variation' ) ){
$attributes = $product->get_attributes();
$variation_names = array();
if( $attributes ){
foreach ( $attributes as $key => $value) {
$variation_key = end(explode('-', $key));
$variation_names[] = ucfirst($variation_key) .' : '. $value;
}
}
echo implode( '<br>', $variation_names );
}
}
The output of this code is as follows: after echo: %da%86%d8%b1%d8%a8%db%8c
and Incompatible with Persian language
I need something like this:
"product Name , color:red, size:85"
source https://stackoverflow.com/questions/70173746/how-to-get-name-attributes-and-name-product-together-after-call-woocommerce-th
Comments
Post a Comment