0

I am selling digital art ebooks with WooCommerce. I would like to provide a list of supplies with affiliate links for each one of these products.

Here is how I am organizing my CPT's:

Custom Post Type: product
    |
    - - > Product 1
    |
    - - > Product 2
    |
    - - > Product ...

Custom Post Type: supply
    |
    - - > Pen 1
    |
    - - > Pen 2
    |
    - - > Paper 1
    |
    - - > Paper 2
    |
    - - > ...

Each supply is part of a custom category:

Custom Taxonomy: supply_category
    |
    - - > Pens
    |       |
    |       - - > Pen 1
    |       |
    |       - - > Pen 2
    |       |
    |       - - > Pen ...
    |
    - - > Paper
    |       |
    |       - - > Paper 1
    |       |
    |       - - > Paper 2
    |       |
    |       - - > Paper ...
    |
    - - > ...

There are several supplies per category to provide our customers with options (price, availability, etc.).

Now, I want to associate my products with the supplies they need. To do so, I associated the supply_category taxonomy with the product CPT. That is, this taxonomy is shared by both the supply and the product CPT. Here is how the product CPT interacts with the taxonomy:

Product 1
    |
    - - belongs to - - > Pens
    |
    - - belongs to - - > Paper
    |
    - - belongs to - - > Any other supply type it may need

My goal is to display the list of supplies that the product requires upon checkout. That is, let's assume the customer purchased Product 1. I will then get all supply_category taxonomies associated with it, and then all supplies under each taxonomy. Add some rearranging and some CSS, and the user will just see a list of recommended supplies to purchase.

My question has to do with the permalinks. I have the following:

  • http://mysite/supplies/ Shows all supply CPTs.
  • http://mysite/supply_category/* Shows all supplies and products under the taxonomy. I can remove the products and show only the supplies via the pre_get_posts filter.

How could I get something like http://mysite/supplies/product-1 or http://mysite/supply_category/pens/product-1? My goal would be to provide a link to the supplies in the product description. Would it be a page template? Can the Rewrite API do this?

Is my data organization the best way to achieve what I want?

Any feedback is appreciated! Thanks!

  • This post appears to be aimed towards generating opinion based answers. This is a forum aimed at solving problems, and I can't really see a problem defined within your post. – EBennett Oct 3 '16 at 8:05
  • While I agree that some of my questions are asking for an opinion, I believe these opinions can be stated objectively (for example, in terms of efficiency), or with pros and cons (for example, a con of having a shared taxonomy for two post types is that the query for the taxonomy must be altered to only display one post type). Furthermore, at the end, I did ask a non-opinion question, which is how to achieve my rewrite of the URLs. – Hernan Villanueva Oct 3 '16 at 14:02

Your Answer

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

Browse other questions tagged or ask your own question.