The information in this thread might be outdated
|

07-26-2013, 10:01 AM
|
 |
Paid Member
|
|
Join Date: Jun 2012
Posts: 6
|
|
Remove quantity from Cart page
I would remove the qty box from the cart page for some products on my facebook shop. I'm not so practical with jQuery but I have written the following script. I would like to remove the div.ecwid-fieldEnvelope-around tag only for the products listed in promo array. It should work because I can see from the alert box the correct index of the element. Could you help me please?
Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof(Ecwid) == 'object') {
Ecwid.OnAPILoaded.add(function() {
Ecwid.OnPageLoaded.add(function(page) {
//alert("My page load handler: "+page.type);
//var $ = window.jQuery;
var x=-1,y=-1;
var cod="cod-sco";
var my_code="eg";
var promo=["SCOACL","SCOACL2","SCOACL3","SCOACL4","SCOACL5","SCOACL6","SCOACL7","SCOACL8","SCOACL9","SCOACL10","SCOSCD","SCOSCD1","SCOSCD2","SCOSCD3","SCOSCL1","SCOSCL2","SCOSCL3","SCOSCL4","SCOSCL6","SCOSCL7"];
if(page.type=="CART"){
var elements=document.getElementsByClassName('ecwid-productBrowser-sku');
if(elements.length>0){
//alert(elements[0].innerHTML);
for(i=0;i<elements.length;i++){
cod=elements[i].innerHTML;
my_code=cod.split(/\s+/g);
for (j=0;j<promo.length;j++){
//check the sku code if it's equal to one of the promo code
if(my_code[1]==promo[j]){
alert(my_code[1].toString()+', index: '+i.toString());
jQuery('div.ecwid-fieldEnvelope-around').eq(i).remove();
y++;
}
}
}
alert(y.toString());
}
}
});
});
}
</script>
|

08-01-2013, 06:53 PM
|
 |
Paid Member
|
|
Join Date: Dec 2011
Location: CA / FL
Posts: 345
|
|
Hey, I don't know if you found a solution to the problem but here's what I came up with:
Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof(Ecwid) == 'object') {
Ecwid.OnAPILoaded.add(function() {
Ecwid.OnPageLoaded.add(function(page) {
if(page.type=="CART"){
var promo=["SCOACL","SCOACL2","SCOACL3","SCOACL4","SCOACL5","SCOACL6","SCOACL7","SCOACL8","SCOACL9","SCOACL10","SCOSCD","SCOSCD1","SCOSCD2","SCOSCD3","SCOSCL1","SCOSCL2","SCOSCL3","SCOSCL4","SCOSCL6","SCOSCL7"];
$("div.ecwid-productBrowser-sku").each(function( index ) {
var cod=$(this).html();
var my_code=cod.split(/\s+/g);
for (x=0;x<my_code.length;x++) {
for (j=0;j<promo.length;j++){
if(my_code[x]==promo[j]){
$(this).closest("tr").find("td div.ecwid-fieldEnvelope-around").remove();
break;
}
}
}
});
}
});
});
}
</script>
It's pretty much the same except uses JQuery to find div.ecwid-productBrowser-sku elements on the page instead of straight javascript (var elements=document.getElementsByClassName('ecwid-productBrowser-sku');).
It gets the innerHTML ($(this).html();) and then looks for the promo code match. Once found it uses .closest to search upwards for the nearest TR then searches down (.find) from there to td with div.ecwid-fieldEnvelope-around and removes it.
I don't know if removing div.ecwid-fieldEnvelope-around will cause problems. If it does you could try changing it hide() instead.
|
The Following 2 Users Say Thank You to smoothsailingco.com For This Useful Post:
|
|

11-06-2013, 11:22 PM
|
 |
Paid Member
|
|
Join Date: Mar 2013
Posts: 11
|
|
Please further explanation
Hi could you explain this a bit more?
I know how to remove the Qty on my productpages, only for specific products, using css.
But accordingly I also need it removed on the cart page for those same products. While Qty for other products remains visibable, editable, ...
Can I use your script to do this? while adding specific productid's??
Wehre do i place the script?
Thanks in advance!
|

11-06-2013, 11:49 PM
|
 |
Paid Member
|
|
Join Date: Dec 2011
Location: CA / FL
Posts: 345
|
|
Quote:
Originally Posted by koorenstem
Hi could you explain this a bit more?
I know how to remove the Qty on my productpages, only for specific products, using css.
But accordingly I also need it removed on the cart page for those same products. While Qty for other products remains visibable, editable, ...
Can I use your script to do this? while adding specific productid's??
Wehre do i place the script?
Thanks in advance!
|
Yeah it should work. You just need to put the SKUs so it knows which ones to hide.
Place the script below the default ecwid script you need for your store.
|
The Following User Says Thank You to smoothsailingco.com For This Useful Post:
|
|

11-08-2013, 01:01 PM
|
 |
Paid Member
|
|
Join Date: Mar 2013
Posts: 11
|
|
Thanks a lot, it's working great!
I have a small side question...
Would this also work with the first string of an SKU?
For the productcategory I want to use this script, I have a range of SKU's starting always with "KP"
...
KP13.06
KP13.09
KP12.02
...
Than I would not have to edit the script afterwards repeatedly...
Thanks!
Jan
|

11-08-2013, 08:54 PM
|
 |
Paid Member
|
|
Join Date: Dec 2011
Location: CA / FL
Posts: 345
|
|
That exact code wouldn't work for that.
You'll need to replace:
Code:
if(my_code[x]==promo[j]){
with
Code:
if(my_code[x]==promo[j] || my_code[x].substring(0,2) == "KP" ){
The new code will also check if the first 2 characters of my_code[x] are equal to KP
|

11-10-2013, 11:24 AM
|
 |
Paid Member
|
|
Join Date: Mar 2013
Posts: 11
|
|
hi thanks!
(Sorry that I keep on asking things. :-). I am not used to javascript)
1. I am a bit confused about the "promo" parameter; I don't understand it; In fact I don't want the promo functionality of Ecwid to interfer with this. I only need to block certain SKU(ranges)
Allthough everything is working great when I add them seperately, and adapt this line of code:
var promo=["KP13.06","KP13.03"] : what do I do with this line of code when I replace the code you suggested?
I shouldn't need It anymore , do I?
2. apart from the "KP"-range I have another range of KPU's that also needs hiding, starting with "CVM": Is it possible to set two ranges in the script?
Thanks a million
Jan
I'll explain my case a bit more.
My webshop: http://www.koorenstem.be/webshop[/URL]
I'm creating a workaround for the lack of "minimum QTY" setting in ecwid. Apart from the books/CD/DVD's I'm selling right now, I want to start selling sheetmusic, ONLY in sets of 5, starting with 15 (so 15, 20, 25, ...)
Take a look at my test items: http://www.koorenstem.be/index.php?o...0&sort=nameAsc
That's why I need to hide or block all regular QTY- references for those products, to keep a more or less consistent shopping experience.
- using css to hide things on product page
- using options and variations (business plan) to define and name, those sets and add different price and weight to them
- using your script to remove the original quantity on cartpage, only for those sheetmusic SKU's starting with "KP****" and "CVM****"
I will have more than hundred items of those eventually...So I prefer not to do this one by one
|

11-11-2013, 12:03 AM
|
 |
Paid Member
|
|
Join Date: Dec 2011
Location: CA / FL
Posts: 345
|
|
NP,
It's named promo because that's what the original poster used and I didn't want to confuse them by changing what they had already used. It might as well be var skus = [x,y,z] since that's what it's looking at.
It's possible to put 2 or more.
Try this code, it's adapted for your situation:
Code:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof(Ecwid) == 'object') {
Ecwid.OnAPILoaded.add(function() {
Ecwid.OnPageLoaded.add(function(page) {
if(page.type=="CART"){
var skus=["KP","CVM"];
$("div.ecwid-productBrowser-sku").each(function( index ) {
var cod=$(this).html();
var my_code=cod.split(/\s+/g);
for (x=0;x<my_code.length;x++) {
for (j=0;j<skus.length;j++){
if(my_code[x].indexOf(skus[j]) == 0){
$(this).closest("tr").find("td div.ecwid-fieldEnvelope-around").remove();
break;
}
}
}
});
}
});
});
}
</script>
It'll now look for skus that start with KP or CVM.
|

11-14-2013, 10:44 PM
|
 |
Paid Member
|
|
Join Date: Mar 2013
Posts: 11
|
|
Thanks. I really appreciate your help.
Its all working fine right now.
Jan
|
The information in this thread might be outdated
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 01:05 PM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.
|