• Resolved rasidrsd

    (@rasidrsd)


    Hey guys,

    in my shop, I have variable products with different variants.

    Now i need to get the String with the Name of the Variant.
    With vard_dump($items) I found that it is listed there, but how can i access it.
    It should look like $varaint = $item[‘iHaveNoIdea’];

    Thank you in advance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Products have a name:
    ‘$_product = new WC_Product($product_id);
    $product_title = $_product->post->post_title;
    `
    but variations don’t have names.

    When you do the var_dump, the first part will say the type of the object, what type is it?

    Thread Starter rasidrsd

    (@rasidrsd)

    $items = $order->get_items();

    so var_dump($items) is a lot of arrays.

    But I have solved it:
    To get the variation name I just read the array with the given name.
    $variation = $item[‘VariationType’];

    ‘VariationType’ is the Property of the Variation.

    Like Color: green | yellow | black

    $variation = $item[‘package’]; woul return the color that was selected.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Get Varaible Product String’ is closed to new replies.