The [withwineapi] shortcode lets a web developer design pages their own way, using live WithWine data. Use it when the ready-made [withwine] widgets don't give you the layout you want.
The full reference is in the plugin Docs, in WithWine under Settings > Website > Wordpress Plugin.
Data you can use
Set type to one of these:
products: all your eCommerce productsproduct: one product. Needsdata_product_id, or use it on your product page.clubsandclub: your clubs, or one club withdata_club_idbrand: your brand's detailsfeatured-lists,ecommerce-filter-lists,tasting-menu-lists: your product lists of that type. Adddata_productlist_idfor one list.my-account-addresses,my-account-orders,my-account-memberships,my-account-payment-methods,my-account-tastings: the logged-in customer's details
To see every field available, put this on a test page:
<pre>[withwineapi type='product' render='' renderformat='prettyjson']</pre>
Templating
Inside a [withwineapi] shortcode, use double curly brackets:
{{name}}shows a field. Use dots for nested fields, for example{{brand.name}}.{{description markdown}}formats the field. Other formats are html (the default), raw, json and url.{{foreach data}}...{{/foreach}}repeats content for each item.{{if price > 50}}Premium{{else}}Everyday{{/if}}shows content conditionally.Functions such as
truncate,uppercase,round,sum,count,sortandfilterchange values, for example{{truncate(description, 100)}}.
Example: all products with a photo, name, description and buy buttons:
[withwineapi type="products"]
{{foreach data}}
<h3>{{name}}</h3>
<img src="https://s3-cdn.withwine.com/{{coverPhotoPath raw}}?w=200" />
<p>{{description}}</p>
[withwine type="product-action-buttons" data_product_id="{{id}}" serverrendering="disabled" /]
{{/foreach}}
[/withwineapi]
Use [withwine type="product-action-buttons"] inside your layout so the try, like and buy buttons work.
Google structured data
Add schema to wrap your JSON in a structured data script, and head to put it in the page head, for example [withwineapi type="product" schema head]. This helps Google show your products in search results.
Things to know
WordPress can't nest shortcodes with the same name, so use the aliases
[withwineapi_1],[withwineapi_2]and so on inside each other.Add
serverrendering='disabled'to[withwine]shortcodes inside a foreach loop to speed up the page.set_not_found_status='true'on a product shortcode returns a proper 404 page when a product isn't found.To show products only some customers can see, turn on Allow Authenticated Server Requests in the plugin settings, and follow the caching rules. See "Which pages must not be cached when using the WithWine WordPress plugin?".
