I'm currently using the 'WP Simple Paypal Shopping Cart' plugin to get up a simple paypal e-commerce site, it's super easy to use, but to save the client having to write shortcode, I've set up custom fields in the back-end to input the product name and price.
The Add to Cart button is generated using a simple piece of shortcode like so:

<?php echo print_wp_cart_button_for_product('Product Name', Product Price); ?>

Obviously replacing Product Name and Product Price with the name and price you're adding to the site. I have 2 custom fields set up like so:

<?php the_field('product_name' ); ?>
<?php the_field('product_price' ); ?>

I'm trying to figure out if there's anyway to put those custom fields inside the shortcode, replacing Product Name and Product Price and thus allowing people to add products to the site without having to write any shortcode. Any suggestions would be greatly appreciated!


If you want to put the custom fields inside the shortcode...you actually should put the custom fields inside the shortcode. Be sure that your fields content does not get echoed, according to ACFs resources you have to use get_field($field_name) within the loop. Try:

<?php echo print_wp_cart_button_for_product(get_field('product_name'), get_field('product_price')); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.