Skip to content

Commit

Permalink
Step 3.2: Add Snipcart buy button
Browse files Browse the repository at this point in the history
  • Loading branch information
yanickouellet committed Apr 29, 2016
1 parent 1a37911 commit 9a10259
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion single-product.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,20 @@
price: <strong><?php echo get_post_meta($id, 'price')[0]; ?>$</strong> <br />
inventory: <strong><?php echo get_post_meta($id, 'inventory')[0]; ?> left</strong>
</div>

<div class="snipcart-button-wrapper">
<button
class="snipcart-add-item"
data-item-id="<?php echo get_post_meta($id, 'id')[0]; ?>"
data-item-name="<?php echo get_the_title(); ?>"
data-item-price="<?php echo get_post_meta($id, 'price')[0]; ?>"
data-item-max-quantity="<?php echo get_post_meta($id, 'inventory')[0]; ?>"
data-item-url="<?php echo get_the_permalink(); ?>"
data-item-image="<?php echo wp_get_attachment_image_src(get_post_thumbnail_id($id), 'single-post-thumbnail')[0]?>"
>
Buy
</button>
</div>

</article>
<?php
// End of the loop.
Expand Down

0 comments on commit 9a10259

Please sign in to comment.