Replace price with "Coming Soon" - Shopify AC and IS

Hi

I’m trying to replace the price of products in Instant search and Autocomplete where the vendor contains ‘Coming Soon’

I have attempted to just hide the price using product tags with Hide pricing in instant search results in Shopify for tagged products but it does not hide the price for me - The thread is from 2 years ago so there may be a different way to do it now.

Any help appreciated!

Hi there,

I believe you can update the transformItems method to include a “showPrice” boolean based on your business logic. e.g. you can probably write something like this

      transformItems: function(products) {
        return products.map(function(product) {
          return algolia.assign({}, product, {
            _distinct: instant.distinct,
            showPrice: showPriceBasedOnBusinessLogic(), // you would have to define how this function behaves
            can_order:
              product.inventory_management !== 'shopify' ||
              product.inventory_policy === 'continue' ||
              product.inventory_quantity > 0,
            translations: algolia.translations,
            queryID: product.__queryID,
            productPosition: product.__position,
            index: instant.search.mainIndex.getIndexName(),
          });
        });

Then you can customise the product template to optionally show the price based on this boolean, as show here:

Let me know if that helped you move forward!
Best,

Thanks Jonathan - That may be past my capability. I found the code section you linked in the instantsearch.js - but i don’t know how / what changes to make to this section or the product template.

@sales3 I have updated my comment to include an example of the transformItems and how you can use it to add a showPrice field.

Hopefully, this gets you closer to solve your issue.
Best,

Thanks Jonathan. Can you point me to where I may be able to get a developer to do this? Im capable to add in and manipulate existing liquid and novice level stuff, but this one is getting the best of me.

I have “coming soon” instead of price when the vendor name contains “soon” on traditional shopify liquid search and collections, but this is a step above me.

I have got this sorted by doing the following

/* sets function for coming soon instead of price based on tag */
function comingSoonNotPrice(tags) {
return tags.includes(‘coming-soon’);
};

instantsearchPrice: function instantsearchPrice (text, render) {
  if (comingSoonNotPrice(this.tags)) { /* if coming soon price then display text */
    return 'Coming Soon';
  }  
  if (!comingSoonNotPrice(this.tags)) { /* if NOT coming soon then price */

Thank you for your help Jonathan