Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

'Add to Cart' Alert Message

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #61  
Old 05-01-2012, 09:27 AM
  swartzieee's Avatar 
swartzieee swartzieee is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 58
 

Default Re: 'Add to Cart' Alert Message

Quote:
Originally Posted by bitofeverything
you have unterminated string literal js errors being generated.

Thanks for pointing this out. I am just not sure of how to get this mod to work with the Ability Template.
__________________
4.7.11
BuckeyeFanApparel.com
Reply With Quote
  #62  
Old 05-01-2012, 09:38 AM
 
bitofeverything bitofeverything is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: 'Add to Cart' Alert Message

It shouldn't have anything todo with the template.
It generally happens when your products have 's in the name.
try replacing your cart_alert.tpl with the following (strips out any ' from the product for the alert)


{if $main eq "product"}

{literal}
<script type="text/javascript">
function Cart_Alert_Product_{/literal}{$product.productid}{literal}() {
Shadowbox.open({player:"html",content:'<div class="alert_msg"><div class="links"><a href="cart.php"><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/cart.png" />{/literal}{$lng.lbl_cart_alert_view}{literal}</a></div><div class="links"><a href="{/literal}{$stored_navigation_script}{literal}" onclick="Shadowbox.close();return false"><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/cart_put.png" />{/literal}{$lng.lbl_cart_alert_continue}{literal}</a></div><div class="links"><a href="cart.php?mode=checkout"><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/cart_go.png" />{/literal}{$lng.lbl_cart_alert_checkout}{literal}</a></div><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/tick.png" />{/literal}{$lng.lbl_cart_alert_added}{literal}<h2>{/literal}{$product.product|replace:'\'':''}{literal }</h2><p>{/literal}<a href="#" onclick="Shadowbox.close();">{include file="product_thumbnail.tpl" productid=$product.image_id image_y=125 product=$product.product|escape tmbn_url=$product.image_url id="product_thumbnail" type=$product.image_type}</a>{literal}</p><p>{/literal}{$lng.lbl_cart_alert_to_cart}{literal}</p><hr /><h3>{/literal}{$lng.lbl_cart_alert_also}{literal}</h3>{/literal}{if $product_links}{section name=product loop=$product_links max=3}<div class="upsell"><a href="product.php?productid={$product_links[product].productid}">{include file="product_thumbnail.tpl" productid=$product_links[product].productid product=$product_links[product].product tmbn_url=$product_links[product].tmbn_url image_y=75}</a><br />{$product_links[product].product|escape:"html"}</div>{/section}{else}{section name=product loop=$recommends max=3}<div class="upsell"><a href="product.php?productid={$recommends[product].productid}">{include file="product_thumbnail.tpl" productid=$recommends[product].productid product=$recommends[product].product tmbn_url=$recommends[product].tmbn_url image_y=75}</a><br />{$recommends[product].product|escape:"html"}</div>{/section}{/if}{literal}<div class="clearing"></div>',height:420,width:600});}
Shadowbox.init();
</script>
{/literal}

{elseif $main eq "search" || $main eq "products" || $main eq "catalog"}

{foreach from=$products item=product name=products}
{literal}
<script type="text/javascript">
function Cart_Alert_Product_{/literal}{$product.productid}{literal}() {
Shadowbox.open({player:"html",content:'<div class="alert_msg"><div class="links"><a href="cart.php"><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/cart.png" />{/literal}{$lng.lbl_cart_alert_view}{literal}</a></div><div class="links"><a href="{/literal}{$stored_navigation_script}{literal}" onclick="Shadowbox.close();return false"><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/cart_put.png" />{/literal}{$lng.lbl_cart_alert_continue}{literal}</a></div><div class="links"><a href="cart.php?mode=checkout"><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/cart_go.png" />{/literal}{$lng.lbl_cart_alert_checkout}{literal}</a></div><img class="icon" src="{/literal}{$SkinDir}{literal}/modules/Cart_Alert/images/tick.png" />{/literal}{$lng.lbl_cart_alert_added}{literal}<h2>{/literal}{$product.product|replace:'\'':''}{literal }</h2><p>{/literal}<a href="#" onclick="Shadowbox.close();"><img src="image.php?id={$product.productid}&type=T" /></a>{literal}</p><p>{/literal}{$lng.lbl_cart_alert_to_cart}{literal}</p><hr /><h3>{/literal}{$lng.lbl_cart_alert_also}{literal}</h3>{/literal}{section name=product loop=$products max=3}<div class="upsell"><a href="product.php?productid={$products[product].productid}">{include file="product_thumbnail.tpl" productid=$products[product].productid product=$products[product].product tmbn_url=$products[product].tmbn_url image_y=75}</a><br />{$products[product].product|escape:"html"}</div>{/section}{literal}<div class="clearing"></div></div>',height:420,width:600});}
Shadowbox.init();
</script>
{/literal}
{/foreach}

{/if}
__________________
Version 4.2.2 [linux] Adult Toy Superstore
Version 4.3.0 [linux] Coochy Outlet
Reply With Quote
  #63  
Old 05-01-2012, 09:42 AM
  swartzieee's Avatar 
swartzieee swartzieee is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 58
 

Default Re: 'Add to Cart' Alert Message

The change has been made but still does not work.
__________________
4.7.11
BuckeyeFanApparel.com
Reply With Quote
  #64  
Old 05-01-2012, 09:56 AM
 
bitofeverything bitofeverything is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: 'Add to Cart' Alert Message

I'm still seeing the js errors - have you cleared your website's cache?
Also, make sure that the javascript code is on one line (line wrap is fine, but new lines will break it)
__________________
Version 4.2.2 [linux] Adult Toy Superstore
Version 4.3.0 [linux] Coochy Outlet
Reply With Quote
  #65  
Old 05-01-2012, 10:08 AM
  swartzieee's Avatar 
swartzieee swartzieee is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 58
 

Default Re: 'Add to Cart' Alert Message

Here is the javascript code

// Widget :: change state to Added
ajax.widgets.add2cart.obj.prototype.doAddedState = function() {
this.button.addClass('do-add2cart-success');

this._freezeBox();

if (this.savedData.box)
this.savedData.box.html(lbl_added);

// Added to Cart Alert Start
window['Cart_Alert_Product_' + this.productid]();
// Added to Cart Alert End

return true;
}
__________________
4.7.11
BuckeyeFanApparel.com
Reply With Quote
  #66  
Old 05-01-2012, 10:19 AM
 
bitofeverything bitofeverything is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: 'Add to Cart' Alert Message

The js errors have todo with the 'content' part of the Shadowbox.open()
Attached Thumbnails
Click image for larger version

Name:	Screen Shot 2012-05-01 at 1.08.35 PM.png
Views:	97
Size:	103.2 KB
ID:	3035  
__________________
Version 4.2.2 [linux] Adult Toy Superstore
Version 4.3.0 [linux] Coochy Outlet
Reply With Quote
  #67  
Old 05-01-2012, 10:22 AM
  swartzieee's Avatar 
swartzieee swartzieee is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 58
 

Default Re: 'Add to Cart' Alert Message

This mod has me stumped. Phil or Steve.. You out there?
__________________
4.7.11
BuckeyeFanApparel.com
Reply With Quote
  #68  
Old 05-01-2012, 10:22 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: 'Add to Cart' Alert Message

If you have ' or " or ; or & in product names, descriptions or images alt text this will break the code unless you escape them
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #69  
Old 05-01-2012, 10:26 AM
  swartzieee's Avatar 
swartzieee swartzieee is offline
 

Advanced Member
  
Join Date: Feb 2010
Posts: 58
 

Default Re: 'Add to Cart' Alert Message

I do not believe I have ' or " or ; or & in product names, descriptions or images alt text but to be safe how do I find out and how do I escape them?
__________________
4.7.11
BuckeyeFanApparel.com
Reply With Quote
  #70  
Old 05-01-2012, 10:31 AM
 
bitofeverything bitofeverything is offline
 

Member
  
Join Date: Sep 2008
Posts: 23
 

Default Re: 'Add to Cart' Alert Message

The js code above (#62) that starts with Shadowbox.open needs to be on one line.
The newline char is breaking the string (starts with ')
__________________
Version 4.2.2 [linux] Adult Toy Superstore
Version 4.3.0 [linux] Coochy Outlet
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:58 PM.

   

 
X-Cart forums © 2001-2020