Shortcode Is it OK to use a variable as an attribute
-
Hi there
New to WC I was hoping a seasoned user could let me know if it is OK to use something like this in the shortcode – On first tests it does seems to work as expected.
echo do_shortcode( '[add_to_cart id="' . $my_variable->ID . '"]' );
I do need some way to add this button and set the product id from a custom field post object
Any advice would be appreciated
All the best
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Shortcode Is it OK to use a variable as an attribute’ is closed to new replies.