@sn4th4n
Hey there, great question. Unfortunately the plugin doesn’t integrate with metafields at the moment. However, there are a couple ways around this.
1. You can install something like ACF on the WordPress site, and add the meta field to the product post that way.
2. You can leverage the plugin’s JavaScript hooks to place custom HTML after the product title. Specifically you would use this hook: https://docs.wpshop.io/#/js/filters/product-title?id=afterproducttitle
I’m able to get that to work on a single product detail page by modifying product-single.php with the following after adding the custom field “product_subtitle”
<div id="product_subtitle"><?php if( get_field('product_subtitle') ) { the_field('product_subtitle'); } ?></div>
I’m having trouble with getting it to work on the page with multiple products. I’m using a custom page with the shortcode method, so WordPress is using page.php and it’s all coming through
<?php the_content(); ?>
I think this is where I’d need to use the hook. I’ve tried stuff like putting this within page.php
<?php
if( get_field('product_subtitle') ) { $mySub = the_field('product_subtitle'); }
echo "<script>wp.hooks.addFilter('after.product.title', 'wpshopify', function (defaultVal, productData) {return \"<div id='product_subtitle'>".$mySub."</div>\"});</script>"
?>
If I substitute a string for $mySub it works fine, putting the same subtitle under each title on the page, but assigning $mySub to a custom field comes up as a blank div because ‘the_field’ I think needs an id as an argument.
I can’t understand how to affect all the instances on the page. I’m not sure if I’m going about this the right way – possibly I need a “while” statement to affect each instance individually? Sorry, my coding ability is a bit limited. I hope you will be able to help.
@sn4th4n
The plugin doesn’t use a normal WordPress loop to display products. Instead, it uses JavaScript to fetch the products, loop through them, and render the info.
So if you want to hook into that loop, you’ll need to leverage the html_template shortcode attribute. Full docs on that here: https://docs.wpshop.io/#/guides/template-overriding?id=html-templates
So basically, you pass it a file name such as custom-products.php which you can then override inside your theme under the folder wps-templates.
This is a Pro feature only.
Hope this helps.
We also want data from metafields Guru.
When looking at your plugin sync job response, there is no data from metafields guru.
How is it possible to fetch this data also and save it in their custom post meta fields via ACF?
Unfortunately my plugin doesn’t sync with the metafields guru app at this time.