Using a cart called Phpurchase,
<strong>Source:</strong> [[LINK href="http://wcdco.info/b9"]]http://wcdco.info/b9[[/LINK]]
I want my author to place a product ID inside a meta field and have that ID echoed into a PHP short code.
<strong>Shortcode Example;</strong>
<?php echo do_shortcode('[cart-button item="PRODUCT ID HERE" showprice="only"]'); ?>
<strong>Current meta code;</strong> <em>(Product ID here)</em>
<?php echo get_post_meta($post->ID, 'price', true);?>
<strong>Broken Example;</strong>
<?php echo do_shortcode('[cart-button item=" <strong><?php echo get_post_meta($post->ID, 'price', true);?></strong> " showprice="only"]'); ?>
<strong>Related question directly to developer;</strong>
<em>“Yes, PHPurchase uses shortcodes that you can either embed directly into you page or post content or you can use in your header, footer, sidebar, etc by using the code:”</em>
<?php echo do_shortcode('[shortcode]'); ?>
Any assistance would be much appreciated!
Edouard Duplessis answers:
<?php echo do_shortcode('[cart-button item="'.get_post_meta($post->ID, 'price', true).'" showprice="only"]'); ?>
West Coast Design Co. comments:
"Could not load product information" ... hmm
West Coast Design Co. comments:
lol … so I entered a ‘price’ instead of an id from the product, it works … thanks!
Nilesh shiragave answers:
<?php echo do_shortcode('[cart-button item="'.get_post_meta($post->ID, 'price', true).'" showprice="only"]'); ?>
Nilesh shiragave comments:
what is price? as you are getting price meta value. if you are entering product id using any other custom field then just replace price with the meta name
<?php echo do_shortcode('[cart-button item="'.get_post_meta($post->ID, 'price', true).'" showprice="only"]'); ?>
Merne Asplund answers:
Nilesh's example should work. If not, try setting the product ID to a variable to use in the do_shortcode:
<?php
$prod_ID = echo get_post_meta($post->ID, 'product_id', true);
echo do_shortcode('[cart-button item="'$prod_ID'" showprice="only"]');
?>