Skip to content

Instantly share code, notes, and snippets.

@axflo
Created January 4, 2019 09:07
Show Gist options
  • Save axflo/0d8f2be6fc0592e09ca34fda343904d3 to your computer and use it in GitHub Desktop.
Save axflo/0d8f2be6fc0592e09ca34fda343904d3 to your computer and use it in GitHub Desktop.
Snippet to be pasted in console in product details page to get data for the product widget
price = cleanPrice();
supply_id = window.location.pathname.split('/')[4];
title = $('.-margin-left-md > h3')[0].innerText;
supplier = $('.product-options__value:has(a)')[0].firstChild.text;
image = $('.img-container-extra-lg')[0].firstChild.src;
aliexpress = false;
function cleanPrice(){
price = $('.product-options__price')[0].innerText;
if (price.indexOf('%') > 0) {
price = price.substring(0, price.indexOf('%') - 2)
}
return price
}
function getDetails() {
if(window.location.pathname.split('/')[4] == undefined){
supply_id = window.location.pathname.split('/')[2];
aliexpress = true;
}
return {supply_id, title, price, supplier, image, aliexpress}
};
getDetails();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment