Ecommerce software home
Shopping Cart Software Forum for Ecommerce Templates
 
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

Find us on Facebook Follow us on Twitter View our YouTube channel
Search our site
 All Forums
 Technical
 PHP (Unix / Linux / Apache) versions
 email for price... suggestions please
Previous Page | Next Page
Author « Topic »
Page: of 5

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/29/2018 :  07:06:24  
thanks Dave.. its sunday... !!!! lol
Your right needed the item for sale burtton checked. - so thats done
Still only showing one instance of the http://www.baby-barn.co.uk/products.php email for price

Kind Regards
Richard

dbdave
ECT Moderator

USA
10264 Posts

Posted - 07/29/2018 :  10:04:10  
Ok, so that seems to be fixed.
I want you to replace the script on the products page with this

<script>
var prodcount = document.getElementsByClassName("product");
for(var i = 0; i < prodcount.length; i++) {
var detectzeroprice = document.getElementById('pricediv' + i).innerText
if (detectzeroprice == '') {
var detectprodid = document.getElementsByClassName('prodname')[i].innerHTML;
var pidis = detectprodid.slice(46);
var pidis2 = pidis.indexOf('"');
var pidis3 = pidis.slice(0 , pidis2);
console.log (detectprodid); //debug this entire line can be removed after you know it works
console.log (pidis3); //debug this entire line can be removed after you know it works
var askque = ('<input value="Email for Price" class="askaquestion" onclick="openEFWindow(\''+pidis3+'\',true)" type="button">');
document.getElementById('pricediv' + i).innerHTML = askque;
console.log ('targeted product price is - pricediv' + i); //debug this entire line can be removed after you know it works
console.log ('current count is - ' + i); //debug this entire line can be removed after you know it works
document.getElementsByClassName("buybutton")[i].style.display='none';}
}
</script>

The issue was the ID of the div attempting to be duplicated, so now we insert the button into a unique ID that already exists.
Maybe the code could be written so it checks to see if a buy button exists for that product so that might fix the issue of a product being marked out of stock.
You would also have a problem if a product had options because the buy button does not show, instead it's a configure button that will show.
For my site (not sure if this is viable for you) we do not show the buy button at all on the products page. We have the details button that basically forces the customer to the detail page to add to cart.
For us, we want the customer to see all of the product details and specs, something that's just too much to show on the products page.

Let me know how this latest revision works, and I'll see if I can revise the code to check for the existence of an add to cart button to overcome potential problems in the future.

Edited by - dbdave on 07/29/2018 10:35:17

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/29/2018 :  23:45:04  
thats got it :)
thank you Dave:)

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 09/18/2018 :  04:36:08  
Hi Dave

sorry to reopen this but I do have a bit of a problem ..

http://www.baby-barn.co.uk/products.php?man=27

there is a little issue with the email for price on the product display list as you can see on the above link.. the email for pice vanishes on 9th mention so I am guessing there is a maximum number of instances that the email for price works on.. is there a fix for that?

Kind Regards
Richard

dbdave
ECT Moderator

USA
10264 Posts

Posted - 09/18/2018 :  08:53:41  
It looks like you still have the debug code active.
Hitting F12 on the keyboard shows the issue.
It looks like may on this product - http://www.baby-barn.co.uk/proddetail.php?prod=EastCoastClaraGrey
perhaps you have the "sell" unticked in the admin for that product.
Is that the case?

That's where the script chokes on that product where it's trying to locate an add to cart button to hide, but cannot find one.

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 09/18/2018 :  09:16:56  
thanks Dave

just checked and it is ticked for sell on that item .

dbdave
ECT Moderator

USA
10264 Posts

Posted - 09/18/2018 :  11:17:45  
I have added some code to check for the buy button and ignore it if not found. Although I am not able to test this on the computer I am on now.

<script>
var prodcount = document.getElementsByClassName("product");
for(var i = 0; i < prodcount.length; i++) {
var detectzeroprice = document.getElementById('pricediv' + i).innerText
if (detectzeroprice == '') {
var detectprodid = document.getElementsByClassName('prodname')[i].innerHTML;
var pidis = detectprodid.slice(46);
var pidis2 = pidis.indexOf('"');
var pidis3 = pidis.slice(0 , pidis2);
console.log (detectprodid); //debug this entire line can be removed after you know it works
console.log (pidis3); //debug this entire line can be removed after you know it works
var askque = ('<input value="Email for Price" class="askaquestion" onclick="openEFWindow(\''+pidis3+'\',true)" type="button">');
document.getElementById('pricediv' + i).innerHTML = askque;
console.log ('targeted product price is - pricediv' + i); //debug this entire line can be removed after you know it works
console.log ('current count is - ' + i); //debug this entire line can be removed after you know it works
if (document.getElementsByClassName("buybutton")[i] != null) {
document.getElementsByClassName("buybutton")[i].style.display='none';}}
}
</script>



Let me know if that makes any difference.

Edited by - dbdave on 09/18/2018 11:18:20

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 09/19/2018 :  00:54:57  
thats done it thank you Dave.. absolute super star!!!!!

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 10/26/2018 :  05:48:20  
think I spoke too soon..

everything works except the mailsend part of it .. oops I have obviously copied something wrong so will work through it now

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 10/26/2018 :  06:01:55  
okay on the proddetail.hphp work fine

on the search.php and products.php pages not so.. the button is created in the right place and in all instances .. clicking on the button pops the window up with the enquiry in it

Finally clicking on the send.. it doesnt send - just sits there looking pretty :)

Any suggestions?

dbdave
ECT Moderator

USA
10264 Posts

Posted - 10/26/2018 :  06:23:10  
We may want to step back and take another look at this with the new features just released

https://www.ecommercetemplates.com/support/forum.asp?FORUM_ID=20

https://www.ecommercetemplates.com/support/topic.asp?TOPIC_ID=110777

I'm thinking it's going to be possible to set a unique class for the products with the email for price and use that to take action. I'll need to time to soak in the new features.

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 10/26/2018 :  10:37:40  
Hi Dave

I have compared the code between the products.php categories.php search.php (which is the same code string) and the proddetail.php which is the simple string

Now the proddetail.php works no issue

the other three on the ast incarnation does everything except send the mail - the previous script you wrote does however work just doesnt display for every instance .. so its so so very close...

I am so sorry for being an absolute pain in the neck

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/03/2020 :  04:54:06  
well just an update on this bit of code for the email for price
It has worked pretty well now for a couple of years BUT as the customers site has got more products in a glitch has emerged
http://www.baby-barn.co.uk/products.php?cat=28
you will see that the "add to cart button has crept in on the 7th item
Very odd!

Any suggestions?

dbdave
ECT Moderator

USA
10264 Posts

Posted - 07/03/2020 :  07:17:29  
Hi Richard, if I recall, this was a problem of not being able to target your products easily.
Now, the latest versions of the cart have the ability to add css classes to each product.
We would need to revisit the code, but I believe it would be something where you would just add a class to products that need attention.

I'll probably need to read through the pages here to refresh my memory, but I expect I can work up something more reliable if you are on a newer version of the cart.

Thanks,
David

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/03/2020 :  07:50:39  
Hi Dave

Hope your well and staying safe in these unusual times.

the version of ect remains unchanged on that site - Im in a bit of a catch 22 here with it in that the customer wont pay me to change the code as it "should have been right the first time around" so any thing I do here is at my cost.

However I would like to see it fixed - the issues are the code works fine 99% of the time - always works well on the product details page, on the products.php and search.php pages it can be a little unreliable depending on the amount of email for a price instances there are - on the link I posted earlier - if I remove the listing that has the additional add to cart option on it - it simply moves to the next mention of email for price so so out pf 6 email for price - the fist and fifth item show the additional add to cart

Anyway look forward to seeing if we can get it sorted :) (I was hoping to retire this year lol)

dbdave
ECT Moderator

USA
10264 Posts

Posted - 07/03/2020 :  08:35:49  
Hi Richard, I understand, but really, I did that free of charge, and I expect you didn't charge him for something I gave you free, so just tell the customer you will give them a full refund on that feature...
Seriously though, I expect they are not following some caveat that is required for my code to work.. I will take a look at it and see if we can tell what specific is causing it. Then you tell them they must create their products in a way for the code to work, or they must update the code.

That seems fair to me.

I expect to have some time this weekend to take a look at it.

PS - If their store has not been updated since this original post, they are missing some important security updates, as well as some great new features.

Thanks,
David

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/03/2020 :  10:17:16  
Thanks Dave

And being honest here I didnt charge the client for anything other than a set up of the site - my money is in the ongoing hosting - but ill put it to them that an update would be worth it

Kind Regards
Richard

dbdave
ECT Moderator

USA
10264 Posts

Posted - 07/05/2020 :  09:54:26  
Hi Richard, I've been looking at this page http://www.baby-barn.co.uk/products.php?cat=28 and I'm not 100% sure what I should be seeing.
The first product has a price (no ask for price button) so I think it should have the add to cart button, no?
I mean there is a price on that one, so it seems like it should be showing an add to cart.
Is the "sell" box unticked on that product in the admin?
That might be throwing off the rest of the page.

Looking through these three pages, there were a few challenges to getting that working on the products pages.
Unless strict guidelines are followed, it will break easily.
It's not really ideal and I think with an update it's likely we can revisit the code and assign a class to products you want to have this feature. I think it would be much more reliable and not break so easily.

Check those products showing on that page to make sure they are following the guides to make this work and et me know what you get.
Update the site and I will rework that code to make it more reliable.

Thanks,
David

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/05/2020 :  23:28:29  
thank you Dave

webspaceunlimited
Advanced Member

United Kingdom
156 Posts

Posted - 07/06/2020 :  04:03:57  
right - fully paid up member again - so thats my retirement put back by 6 months ... lol

Seriously though 20 years of web building and hosting - and trying to retire - so many clients have moved to wordpress whiuch I hate with a passion and still only a few left on old php scripted sites -

I think I have just this client left now on ect..

Anyway if we can avoid as much work as possible for me would be good

I have the updater - do you want me to apply that?
Page: of 5 « Topic »  
Previous Page | Next Page
Jump To:
Shopping Cart Software Forum for Ecommerce Templates © 2002-2022 ecommercetemplates.com
This page was generated in 0.05 seconds. Snitz Forums 2000