Hi
I am using the Simple WP Shopping Cart
They offer short code and php options for inserting a button which is:
<?php echo print_wp_cart_button_for_product(’PRODUCT-NAME’, PRODUCT-PRICE); ?>
or
[wp_cart:PRODUCT-NAME:price:PRODUCT-PRICE:end]
As you can see for each button you need to set the name and price.
I have made a custom post type with custom fields using ACF plugin (advanced custom fields plugin)
I have successfully called some of those custom fields into my template but I would like to insert the "price" custom field and the "post title" into the shortcode (or php) of the shop button.
for example
echo '<h2>';the_title();echo '</h2>';
echo the_field('price');
echo '<img src="';the_field('image');echo '">';
echo print_wp_cart_button_for_product(‘echo the_title();’, echo the_field('price'); );
the_excerpt();
I have tried several variations but it either doesnt do anything or it breaks the page.
I am calling the custom post type in groups of 3 as well, in line with the layout I want to achieve so the full code to pull the posts is
<?php
// Show a selected number of posts per row
$posts_per_row = 3;
$posts_per_page = 9;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => $posts_per_page,
'paged' => $paged,
'post_type' => product,
);
query_posts($args);
if (have_posts()) {
while (have_posts()) {
the_post();
if ((++$post_counter % $posts_per_row) == 1 || $posts_per_row == 1) {
if ($post_counter > 1) {
echo "</div><!-- End of post_row -->\n"; // End previous row
}
echo "<div class='post_row'>\n"; // Start a new row
}
echo "<div class='grid_4'>\n"; // Start one post
// Output post data here
echo '<h2>';the_title();echo '</h2>';
echo the_field('price');
echo '<img src="';the_field('image');echo '">';
echo print_wp_cart_button_for_product(‘wordpress’, 7.50);
the_excerpt();
echo "</div><!-- End of post_class -->\n"; // End of post
} ?>
</div><!-- End of post_row -->
<div class='clear'></div>
<div>
<div><?php next_posts_link('« Older Entries') ?></div>
<div><?php previous_posts_link('Newer Entries »') ?></div>
</div>
<?php } else {
// Code for no posts found
}
?>
If that helps any further.
Hopefully I have explained clearly enough that someone might know what I want to do, even if you dont know how to solve it but you know what terms I should be googling for etc please let me know.
Thanks in advance