Announcement

Collapse
No announcement yet.

Pass cart product detail to mysql

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

    #16
    After reading this thread earlier in the day I thought I'd have a go at logging stuff in mysql on checkout.

    I got it to work very well.

    Each product withquantity that gets through checkout is sent to mysql and timestamped. I then used a simple select query to call a 'best-sellers' list. (Im on V7 btw)

    This is all it took ->

    On Act_Order_04.html / receipt template I set some javascript variable

    PHP Code:
    <script type="text/javascript" language="javascript">
    var 
    checkout 'true';    
    var 
    orderno 'NETQUOTEVAR:THEORDERNUMBER';
    var 
    date 'NETQUOTEVAR:CURRENTDATE';
    </
    script
    I then put some javascript into Act_ShoppingCartXML.html - inside the orderline loop

    PHP Code:
    <Actinic:XMLTEMPLATE NAME="OrderLine">
                <!-- 
    Order line begin -->
                    <
    TR>
                        <
    TD COLSPAN="NETQUOTEVAR:PRODUCTCOLSPAN" valign="top" BGCOLOR="NETQUOTEVAR:CHECKOUTBG">
                            <
    Actinic:XMLTEMPLATE NAME="ProductLine">
                        <!-- 
    Product line begin -->
                            <
    TABLE BORDER=0 WIDTH=100CELLSPACING=0 CELLPADDING=0>
                                <
    TR>
                                    
    NETQUOTEDEL:REFERENCE
                                    
    <TD WIDTH=100 valign="top"><SPAN CLASS="actxxsmall">NETQUOTEVAR:PRODREF</SPAN>

    <!-- 
    Send Cart Details to PHP script -->
    <
    script type="text/javascript" language="javascript">
                                    if (
    checkout == 'true') {
    var 
    product 'NETQUOTEVAR:PRODREF';
    var 
    quantity 'NETQUOTEVAR:QUANTITY';
    document.write('<img src="https://www.myserver.com/actinic/log.php?order=' +  orderno '&date=' +  date '&content=' product '&quant=' +  quantity '&accno=' accno '" style="display:none"/>');    
    };    
    </
    script
    Because the shopping cart template is used on multiple pages before the receipt page I make sure that checkout == 'true' - The if statement will only be true on the receipt page where I set var checkout = 'true'; on Act_Order_04.html

    Hope this helps.

    - M.

    Comment

    Working...
    X