Daryl Glass
Daryl Glass

Reputation: 19

Change a static ID into a variable

I hope someone can help me, I am sure this is simple but for the life of me I cannot get it right.

<?php shopp('storefront','product', 'id=36' ); ?>

I want to make the 'id=36' a variable which is called from a custom meta box. The function I am using to call the ID number is $my_meta['price']

So I ended up with something like this: <?php shopp('storefront','product', 'id=$my_meta['price']' ); ?>Which doesn't work. When I insert this $my_meta['price'] into a post it displays the number successfully, so that is all working.

Can someone please help me figure this out?

Please and thanks.

Upvotes: 0

Views: 76

Answers (2)

Kevin Ji
Kevin Ji

Reputation: 10489

You need to use double quotes with curly braces if you want to expand variables within strings:

<?php shopp('storefront', 'product', "id={$my_meta['price']}"); ?>

If you wish to only use single quotes, you can append the variable to the string:

<?php shopp('storefront', 'product', 'id=' . $my_meta['price']); ?>

Upvotes: 0

Tobias Golbs
Tobias Golbs

Reputation: 4616

Try <?php shopp('storefront','product', "id=" . $my_meta['price'] ); ?>

Upvotes: 0

Related Questions