We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20178
    • 82 Posts
    I’ve been trying to get simplecart.js going with modx - I’ve managed to get it going with paypal- it just works -easy but i would like to just send an email confirmation rather than process the order.

    i’m using the emailer branch of it and all the files i’ve used i here;

    https://github.com/thewojogroup/simplecart-js/tree/email

    the issue i seem to be having is communicating with the email.php file

    i’ve got it running on a test html page fine outside of modx - so the root of the problem is trying to reference the email.php file - my knowledge of php and js really isnt good enough to know where to turm - im trying to read up on snippets as im thinking there needs to be a snippet call and an ’email’ snippet. - and then would i call it from within the js file ?

    my js ;


    me.emailCheckout = function() {
    var div = me.updateCartView( document.createElement("div") );
    div = "<div class=’simpleCart_items’>" + div.innerHTML + "</div>";
    $.post("[[emailer]]" , {div:div} , function(data) {
    alert( data );
    });
    };


    posting to the [[emailer]] snippet;

    <?php
    PHP
    
    $ADMIN_EMAIL   = "[email protected]"; // Email address that the cart info will be sent to
    $EMAIL_SUBJECT   = "simpleCart(js) has been submitted";
    
    
    if( !isset($_POST['div']) ){
      echo "no data provided";
      return;
    }
      
      
    $div = $_POST['div'];
    
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Additional headers
    $headers .= 'To: <' . $ADMIN_EMAIL . ">\r\n";
    $headers .= "From: \"simpleCart(js)\" <[email protected]> \r\n";
    
    $body = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
      \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
    
    <html xmlns=\"http://www.w3.org/1999/xhtml\" dir=\"ltr\" lang=\"en-US\">
    
    <head>
    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /><title>" . $EMAIL_SUBJECT . "</title></head><body>" . $div . "</body></html>";
    $subject = $EMAIL_SUBJECT;
    
    mail( $ADMIN_EMAIL, $subject, $body, $headers);
    


    http://megawattmedia.co.uk/shop.html

    i think this could be a great simple cart solution to release to the community be someone more competent like yourself.

    any help much needed and appreciated dont think it’s too far off!