Where can I find an put this code - Cannot find the theme.js.liquid file as stated in the descriptio

Where can I find an put this code - Cannot find the theme.js.liquid file as stated in the descriptio

46855004463
Tourist
19 0 2

Hello,

I want to use this script on my website but cannot find the file to edit the code. I use the DAWN theme.

 

From instructions:
"Insert something like this at the end of the file theme.js.liquid (visit your theme files in the Shopify admin > Online store > Themes > Live theme: Actions dropdown > Edit code > unfold the Assets folder on the left):"


 

CODE: 

/**
 * Insert text near the Buy button on the product page.
 *
 * E.g. "18 people are viewing this product right now."
 */
document.addEventListener('DOMContentLoaded', function () {
	// Minimum view count
	var minViews = 2;
	// Maximum view count
	var maxViews = 20;
	// Text to show after the view count number
	var text = 'people are viewing this product right now.';

	// Create the new element to display on the page
	var $viewCountElement = document.createElement('div');
	$viewCountElement.className = 'view-count shopify-payment-button';
	$viewCountElement.innerText = Math.floor(Math.random() * (maxViews - minViews) + minViews) + ' ' + text;

	// Determine where to put the new element
	var $form = document.querySelector('.template-product .ProductForm');
	var $pickupOptions = document.querySelector('.template-product .ProductMeta__StoreAvailabilityContainer');
	if ($pickupOptions) {
		// If there's currently an element about the pickup options on the page, insert our view count element before that
		$pickupOptions.parentElement.insertBefore($viewCountElement, $pickupOptions);
	} else {
		// If there's no pickup options element on the page, just place the view count element at the end of the product form
		$form.appendChild($viewCountElement);
	}
});

 

Replies 6 (6)

GemPages
Shopify Partner
5625 1261 1243

Hello @46855004463

It's GemPages support team and glad to support you today.

 

Dawn theme have not file theme.js.liquid It is use file global.js so you can paste it to this file

GemPages_0-1670686483669.png

If you require any further information, feel free to contact me.

 

Best regards,
GemPages Support Team

GemPages - Build any high-converting store pages for any business


- If you find my reply helpful, please hit Like and Mark as Solution
- Get connected: App Store | Blog | Community | Help Center
46855004463
Tourist
19 0 2

Hello,
This information I managed to google. But when I use the code in global.js nothing happens 😕

Thank you

ghdfgdrg
Visitor
1 0 0

This data I figured out how to research. In any case, when I utilize the code in global.js nothing occurs. sauces at popeyes

bulleyes
Visitor
1 0 0

I think it will no have issue bcz of global.js Arby's breakfast menu

Rockjack2
Visitor
2 0 0

I managed to research and gather the required data. However, when I tried using the code from global.js, nothing happened, and I couldn't get it to work as expected. blue fish happy hour

haider484
Visitor
1 0 0

If you're using the DAWN theme on your website, locating the theme.js.liquid file is crucial for implementing the script. It's a bit like finding the right material for your flooring ; in this case, the code is the foundation of your site's functionality. To edit the code effectively, follow the provided instructions to access the theme files in your Shopify admin. Once you locate the theme.js.liquid file, you can seamlessly integrate the script and enhance the functionality of your website.