Jump to content

ShoppingCart: one page for two products


sarah_hue
 Share

Recommended Posts

Hi,

now I need your help getting an idea:

I've got a page "The Jungle Book" containing details on the book by Rudyard Kipling. With ShoppingCart module, I'd like to offer the book both as a PDF for download as well as a printed version.

I added the sc_price and sc_qty fields to the page, which is half of what I need: Now the page renders a button to put the book (let's say it's PDF version) into the shopping cart.

How do I add a second version of this product on the same page? Titel, price and all the details will be the same, only the actual type of the product (digital version instead of printed version) differs. Since there will be many different pages with books, manually adding a second page for the printed book is not an option.

Thanks for your ideas!

sarah

P.S.: There is this post by apeisa on adding different variations of a product into the shopping cart. But I haven't figured out what's a good way to refer back to the original page (for getting the product information) once a variation is placed in cart.

Edited by sarah_hue
Link to comment
Share on other sites

Here's what I did as a workaround: I've got this page

  • /books/the_jungle_book (template: book)

and added a quasi duplicate of this page

  • /pdfs/the_jungle_book (template: pdf) – containing only the necessary fields title, author, sc_price, sc_qty, with a 1:1 content copy of the fields in page /books/the_jungle_book

Then for the ShoppingCart "purchase" button, I use (in the template file books.php):

// book
$content .= $modules->get("ShoppingCart")->renderAddToCart());
 
// pdf
$pdf = $pages->find('template=pdf,title='.$page->title)->first();
$content .= $modules->get("ShoppingCart")->renderAddToCart($pdf));

I know this is not elegant at all, but at least it works for now. Yes, I did write: "Since there will be many different pages with books, manually adding a second page for the printed book is not an option." Since the workaround requires to manually add both a 'book' and a 'pdf' page: How can I create the pdf page automatically once a user creates the book page?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...