• Hello,

    I’ve created a custom page, that adds an item variation to the cart when a product id and variation id are supplied. However I’m finding it impossible to retrieve the name of the variation for use in a success message.

    “VARIATION NAME has been added to the cart!”

    Does anybody know how to achieve this? What I’m referring to as the VARIABLE NAME is the text that is in the dropdown on the product page for the add to cart button..

    Any direction or help is greatly appreciated!

    https://ww.wp.xz.cn/plugins/woocommerce/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Austin,

    I’ve created a custom page, that adds an item variation to the cart when a product id and variation id are supplied. However I’m finding it impossible to retrieve the name of the variation for use in a success message.

    As you have the product ID present, I’d say a good starting point would be to sanitise this value (make sure it’s an integer), and then instantiate a $product_to_use = new WC_Product( $product_id );.

    From there, you can var_dump() on $product_to_use and see the various properties available to you.

    I hope this helps as a starting point. 🙂

    Thread Starter AustinTBiggs

    (@austintbiggs)

    Thank you Matt, I’ll give this a try and post back!

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

The topic ‘Get Variable Name?’ is closed to new replies.