October 30, 2009 at 7:26 pm #384syncboxMember
This is kind of an advanced question about how you would write your template cart button function call when the information about the product and price is contained and managed in WordPress using a Custom Field Template plugin’s write screen (these are still just custom field meta data) but the CFT makes it far easier for the end user to manage the content of the site.
For example, your function is called with:
<?php echo print_wp_cart_button_for_product(‘PRODUCT-NAME’, PRODUCT-PRICE); ?>
and to get the info for the name and price via my template, I use the following:
<?php echo c2c_get_custom(‘MMTname’); ?> or <?php echo c2c_get_custom(‘MMTprice’); ?>
How can I combine these functions?
I’m generally okay with writing echo statements that write out content and call a function, like
echo ‘<h2>’.the_title().'</h2>’; and figure it must be something like that, but?
Help greatly appreciated!October 30, 2009 at 10:54 pm #15798syncboxMember
Got it worked out. I just put the metadata into a couple of $vars and then use those, as in:
$prodname = <?php echo c2c_get_custom(‘MMTname’); ?>
$prodprice = <?php echo c2c_get_custom(‘MMTprice’); ?>
then when I call the add to cart button, use:
<?php echo print_wp_cart_button_for_product($prodname, $prodprice); ?>July 25, 2010 at 3:59 am #15799bobsneadMember
I used the same principle to utilize the wordpress custom meta fields to get the same result. So I have a two fields named productname and productprice that I can enter values into and it works great.
<?php $product_id = get_post_meta($post->ID, ‘productname’, true);
$product_price = get_post_meta($post->ID, ‘productprice’, true);
echo echo print_wp_cart_button_for_product($product_id, $product_price); ?>
My question now is how do I get variations, like for tshirt size?July 25, 2010 at 3:15 pm #15800bobsneadMember
Well I figured out something that will work. I mainly needed to be able to put the cart button in the sidebar, so for the time being I’m using this:
$product = get_post_meta( post->ID, ‘product’, true);
Then I just put the full shortcode string with all variations into the ‘product’ meta field of my post. Quick and dirty, I don’t mind that.
- You must be logged in to reply to this topic.