You don't need to be an 'investor' to invest in Singletrack: 6 days left: 95% of target - Find out more
I’m not trying to steal anything, I just want to have some stock data for custom options on our products, which use materials we don’t keep in stock.
It’s the green “xxx in stock” or red “on back order” text I want to copy over to our product pages, from here:
https://www.allparts.uk.com/products/grill-cloth-ampeg-style-black-silver-36-width-per-yard
(I’m not a web designer, I’m just making it up as I go along!)
Any experts here?
Sure, write some code to grab that page, parse it, extract the bits you want, and then put it in your own page.
Anything further than that would need a lot more details about how your site works.
A better solution would be to speak to allparts and ask if they have a machine readable stock database that you can access easily, without all the pain of doing what you want.
I'm sure someone here will help. The MTB coding experts sorted out my PHP Image problem the other day.
Could IFRAME be of use?
A lot of sites have an API (Application Programming Interface) that allows for this. It's how sites pull data from Strava and similar. If Allparts do have an API then there'll be a few limitations, usually things like a maximum number of requests per hour/day/week.
Then your problems become:
1. How to formulate the request.
2. How to handle the response.
3. How to dynamically update your site with that information.
There's a few ways to go about this, as ever, each comes with its own pros and cons. You could do it on the server just making a request every few hours then caching the response at your end and inserting the data into your pages. Alternatively you could do it from the browser side with JavaScript. Very lightweight in terms of programming but you have to get round the inbuilt security features of browsers that are there to prevent this cross-site access to begin with!
At its easiest it could be a couple of dozen of lines of code, at its worst it could be a lot. The following Javascript could do it:
fetch("https://www.allparts.uk.com/stock" + query)
.then((response) => response.json())
.then((text) => filter(rules))
.then((data) => {
document.getElementById('stockLevels').innerHTML = data.stockLevel;
});
You'd need to define "query", rules and the other variables but in theory that should work.
Thanks! This is the page it’s going on:
https://barefacedaudio.com/products/custom-tolex
It’s not the prettiest, it’s already borrowing the images from the allparts site, hence the random sizes. The cabs are pretty, the website just has to be informative!
the data appears to be in here
https://www.allparts.uk.com/products/grill-cloth-ampeg-style-black-silver-36-width-per-yard.js
which nicely has CORS to allow access from anywhere, so to mod whitestones code with jquery, this would place the info in a div on your page with 'grill-cloth-stock' as the ID.
$.get( "https://www.allparts.uk.com/products/grill-cloth-ampeg-style-black-silver-36-width-per-yard.js", function( data ) {
$( "#grill-cloth-stock" ).html( data.variants[0].inventory_quantity + " in stock" );
});
ah I'm bored and I like hacking..
load your page, press f12 and put this on the console. voila
$.getJSON( "https://www.allparts.uk.com/products/grill-cloth-ampeg-style-black-silver-36-width-per-yard.js", function( data ) {
$("div:contains('British Raging Green')").last().append( data.variants[0].inventory_quantity + " in stock" );
});
(ps, this is horrible code as your page dom is nasty)
your page dom is nasty
That was my thought on looking at the source. I think it's been generated by something like Dreamweaver.
Generally the cleaner, tidier, more correct code and markup are then the easier it is to work with.
Thank you! I don’t fully understand what you’re all saying but I’ll have a fiddle tomorrow and see what happens, and then return for help! 😉
Our site is a Shopify one which was built and somewhat over-complicated by two ex-employees, quite a few plug-ins and apps and extra code, which has made it rather difficult to edit (far too many pages have to be edited in the code rather than the cms’s wysiwyg interface). I’m trying to simplify it but I’m not a web designer or coder so my abilities are even more limited than my budget!
They are lovely looking amps.
But your home page is a shocker.
A couple of videos like you're half way through a chat.
Put a proper intro in before you do anything else.
"we build guitar? & bass? Amps in timbuktu using unicorn pubes skyhooks" etc a couple of pictures rather than a list of all your products and stuff.
I'm so stuck with editing the home page on Shopify, it's a complete nightmare! Any help appreciated. Another problem I have is the top menu vanishing on a small screen like a phone...
It's worth using the developer tools in whichever browser you prefer - they have a variety of tabs/views on a page, one (in Chrome dev tools) is "Elements" which is the DOM tree of the page, highlight a line in the tool and it highlights what that line refers to on the page. Very useful in figuring out what's what.
The disappearing menu is probably because the page isn't responsive in design. Again dev tools often have an option to pretend to be a phone, tablet, etc so you can see how it looks on one of those devices while still on your desktop.
I ran the home page through the W3C validator - https://validator.w3.org/nu/?doc=https%3A%2F%2Fbarefacedaudio.com%2Fproducts%2Fcustom-tolex but given your stated level of expertise you probably won't understand what the errors mean.
Thanks! I vaguely understand that - it looks like certain bits of code are broken or incomplete. Obviously it would be better if that wasn’t the case but what is the actual negative impact in practice?
The site is meant to be responsive, so I you shrink the screen width it changes how it formats things. Once you go below a certain width the menu hamburger vanishes, which is a bit of a problem - it’s not that it’s off to the right if you scroll (like an unresponsive site), it’s not there at all!
Regarding the home page, could I just replace it with a simple page with the same name? The current one is some automatic Shopify thing and it’s all but impossible to edit.
@5lab I'm already stuck, sorry! Problem no. 1 is I don't know what a console is...
I guess I need to make a list of what needs fixing/improving on the site and then see if someone competent can sort it out at a reasonable price (or in exchange for a nice cab for guitar or bass!) because it's just too complex for my level of understanding.
I think what you need there is to start again with a web developer who will discuss your needs and produce something to your requirements that you can maintain. Do you get an amp builder to build your amps, or a greengrocer?
Aside, your embedded 'scam' Instagram post on the front page may be true but doesn't exactly scream "professional".
Im a Shopify whizz.
Unfortunately I don't play guitar.
Drop me a line and I will see if I can help you out.