Announcement

Collapse
No announcement yet.

"Add to cart" button in external window?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    "Add to cart" button in external window?

    My site has Javascript pop-up windows with more information on each product (produced in Dreamweaver). Is it possible to include an "add to cart" button on these pages?

    I know Actinic v6 now supports this, but I was wondering if there is any way to do this in v5 using javascript or something.

    pangit

    #2
    Here's some code I was working on some time ago to allow for an Add to Cart on V5 popup pages. If I remember right this worked by replacing the Add to Cart on the product page with a Popup Page button and the popup had the Add to Cart. I had some trouble getting this to work properly with Netscape and fudged it to leave add to cart on the product page if Netscape was being used. It's not exactly what you want but may help you get there. You could use CUSTOMVARs containing additional text and image names for the popup page and get close to the V6 way of working.

    Code:
    These examples are based on the Theme as supplied with the V5 demo site.  
    They will only work if your product references are Alphanumeric ( _ and $ are also allowed).
    Actinic generated product references are numeric and thus are OK.
    
    WORK IN PROGRESS - DOES NOT WORK WITH NETSCAPE 
       workaround is to display Add to Cart on product page if Netscape browser.
    
    You will have to edit Act_primary.html and Act_ProductBody.html so make backups of them. 
    
    Look in Act_Primary.html for the line
    
    	<FORM METHOD=NETQUOTEVAR:CGIMETHOD ACTION="NETQUOTEVAR:CGIURL" NETQUOTEVAR:ONSUBMIT>
    
    Add this bit of code below it (note the var FormCode.. must be on one long line ending with ;)
    
    	<script language=JavaScript>
    	 var FormCode = '<FORM METHOD=NETQUOTEVAR:CGIMETHOD ACTION="NETQUOTEVAR:CGIURL" target="mainwin" onsubmit="window.close();return true;">';
             window.name = 'mainwin';
    	</script>
    
    Look in Act_ProductBody.html for the line
    
    	<INPUT TYPE=HIDDEN NAME="PAGE" VALUE="PRODUCT">
    
    Add this bit of code below it
    
    	<script language=JavaScript>
    	 FormCode += '<INPUT TYPE=HIDDEN NAME="SID" VALUE="NETQUOTEVAR:SECTIONID"><INPUT TYPE=HIDDEN NAME="PAGE" VALUE="PRODUCT">';
             var cwin;
    	</script>
    
    Make a new copy of Act_ProductLine.html called PopupProductLine.html
    
    Edit PopupProductLine.html
    
    ** look for the line
    
    	<TD COLSPAN="2" ALIGN=LEFT><Actinic:ACTIONS><FONT FACE=ARIAL>NETQUOTEVAR:ADDTOCARTBUTTON</FONT></Actinic:ACTIONS>NETQUOTEVAR:TEMPLATEENDXML</TD>
    
    Replace that with
    
    	<TD COLSPAN="2" ALIGN=LEFT>
              <script language=JavaScript>
                var ActStart_NETQUOTEVAR:PRODUCTREFERENCE = FormCode + '<B>NETQUOTEVAR:PRODUCTNAME</B><br>';
                ActStart_NETQUOTEVAR:PRODUCTREFERENCE += '<B>NETQUOTEVAR:PRODUCTPRICE</B><br>';
                ActCart_NETQUOTEVAR:PRODUCTREFERENCE = '<Actinic:ACTIONS><FONT FACE=ARIAL>NETQUOTEVAR:ADDTOCARTBUTTON</FONT></Actinic:ACTIONS>';
    	    ActEnd_NETQUOTEVAR:PRODUCTREFERENCE = '<input type=button value="Close" onclick="javascript:window.close()"></form>';
              if ( navigator.appName.indexOf('Microsoft') != -1 )
                {
    	    document.write('<input type=button value="Click Me" ', 
                 'onclick="javascript:if(cwin && (! cwin.closed))cwin.close();',
                 "cwin=window.open('','mywin','width=400,height=400,scrollbars=yes,resizable=yes');",
                 'cwin.document.write(ActStart_NETQUOTEVAR:PRODUCTREFERENCE,ActCart_NETQUOTEVAR:PRODUCTREFERENCE,ActEnd_NETQUOTEVAR:PRODUCTREFERENCE);">');
                 }
               else
                 {
                 document.write(ActCart_NETQUOTEVAR:PRODUCTREFERENCE);
                 }
    	  </script>
    	  NETQUOTEVAR:TEMPLATEENDXML
    	</TD>
    
    Note your template may have more than one occurence of the line at ** above.  If so, repeat from **.
    
    Now use the PopupProductLine.html template for those products you wish to have a pop-up add to cart page on.

    Norman
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      The above was how to add popup pages with Add to cart functionality to V5.

      If you just want to add a product to the cart (with no components or attributes) from any page that's nothing to do with Actinic then:-

      Adding to cart from outside Actinic


      Code:
      <a href="http://www.myserver.com/cgi-bin/ca000001.pl?RANDOM=NETQUOTEVAR%3ARANDOM&SID=123&ACTINIC_REFERRER=http://www.myserver.com/acatalog/Section_123.html&PAGE=PRODUCT&MyProdRef.x=1&MyProdRef.y=1">Click to buy</a>
      Will do it from anywhere. It just emulates the fields from the product form that would get passed to the cart script.

      Where MyProdRef is the product reference, Section_123.html refers to the products page name and SID=123 uses just the final numeric part of the product's page name (if using default page names). If using user defined page names you'll have to look in each pages source for the SID=nnn value.

      You can select components and attribute choices on your home brewed popups but it requires additional parameters on the page call and is rather complex to go into here.

      Norman
      Norman - www.drillpine.biz
      Edinburgh, U K / Bitez, Turkey

      Comment


        #4
        Thanks very much for that. I'll give it a go and see if it works!

        pangit

        Comment

        Working...
        X