In WooCommerce, I would like to create a function which outputs a simple "list" of data, for each variation or a variable product. Or, if a simple product, then the details of that product itself. The details I need to include for each are: regular price
, size attribute
(used for the variations) sale price
, stock
.
This is for a "catalog" version of WooCommerce product pages, so there will be no actual Add To Cart button or Variation dropdown. Instead, I want to present the information of each product/variation to the user.
I need to output the data of each, as list items within a <ul>
. A new <ul>
for each variation.
Example of a product with 3 variations:
<div class="fs-product-data-wrapper">
<ul>
<li class="fs-data-price">$49.98 ea.</li>
<li class="fs-data-size">Size: 15-18"</li>
<li class="fs-data-sale">$49.98 ea. Preferred Customer Price</li>
<li class="fs-data-stock">Quantity in Stock: 40</li>
</ul>
<ul>
<li class="fs-data-price">$799.98 ea.</li>
<li class="fs-data-size">Size: 2-2.5'</li>
<li class="fs-data-sale">$67.98 ea. Preferred Customer Price</li>
<li class="fs-data-stock">Quantity in Stock: 15</li>
</ul>
<ul>
<li class="fs-data-price">$29.98 ea.</li>
<li class="fs-data-size">Size: 12"</li>
<li class="fs-data-sale">$19.98 ea. Preferred Customer Price</li>
<li class="fs-data-stock">Quantity in Stock: 0</li>
</ul>
</div>
Example of a product with no variations, but is just a simple product:
<div class="fs-product-data-wrapper">
<ul>
<li class="fs-data-price">$99.98 ea.</li>
<li class="fs-data-size">Size: 15-18"</li>
<li class="fs-data-sale">$99.98 ea. Preferred Customer Price</li>
<li class="fs-data-stock">Quantity in Stock: 32</li>
</ul>
</div>
Screenshot of example:
I can manage the CSS of it. I just need the ability to produce this data within a ul
for each "option". Ideally this would be done via shortcode too, since I will be populating it via a page builder template. But I could make due if it hooks into an existing product page hook. Perhaps woocommerce_after_single_product
.