Added customer company name for shipping

master
Mark Moffat 2020-03-07 20:07:49 +10:30
parent e64905eddd
commit f3a7231016
15 changed files with 28 additions and 3 deletions

View File

@ -196,5 +196,6 @@
"Users": "Users", "Users": "Users",
"Create Order": "Create Order", "Create Order": "Create Order",
"User edit": "User edit", "User edit": "User edit",
"Logout": "Logout" "Logout": "Logout",
"Company": "Company"
} }

View File

@ -64,6 +64,7 @@ $(document).ready(function (){
url: '/adyen/checkout_action', url: '/adyen/checkout_action',
data: { data: {
shipEmail: $('#shipEmail').val(), shipEmail: $('#shipEmail').val(),
shipCompany: $('#shipCompany').val(),
shipFirstname: $('#shipFirstname').val(), shipFirstname: $('#shipFirstname').val(),
shipLastname: $('#shipLastname').val(), shipLastname: $('#shipLastname').val(),
shipAddr1: $('#shipAddr1').val(), shipAddr1: $('#shipAddr1').val(),

View File

@ -1 +1 @@
function showNotification(e,t,a,i){a=a||!1,i=i||null,$("#notify_message").removeClass(),$("#notify_message").addClass("alert-"+t),$("#notify_message").html(e),$("#notify_message").slideDown(600).delay(2500).slideUp(600,function(){i&&(window.location=i),!0===a&&location.reload()})}function slugify(e){return $.trim(e).replace(/[^a-z0-9-æøå]/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").replace(/æ/gi,"ae").replace(/ø/gi,"oe").replace(/å/gi,"a").toLowerCase()}$(document).ready(function(){$("#stripeButton").validator().on("click",function(e){(e.preventDefault(),0===$("#shipping-form").validator("validate").has(".has-error").length)&&window.StripeCheckout.configure({key:$("#stripeButton").data("key"),image:$("#stripeButton").data("image"),locale:"auto",token:function(e){$("#stripeButton").data("subscription")&&$("#shipping-form").append('<input type="hidden" name="stripePlan" value="'+$("#stripeButton").data("subscription")+'" />'),$("#shipping-form").append('<input type="hidden" name="stripeToken" value="'+e.id+'" />'),$("#shipping-form").submit()}}).open({email:$("#stripeButton").data("email"),name:$("#stripeButton").data("name"),description:$("#stripeButton").data("description"),zipCode:$("#stripeButton").data("zipCode"),amount:$("#stripeButton").data("amount"),currency:$("#stripeButton").data("currency"),subscription:$("#stripeButton").data("subscription")})}),$("#adyen-dropin").length>0&&$.ajax({method:"POST",url:"/adyen/setup"}).done(function(e){const t={locale:"en-AU",environment:e.environment.toLowerCase(),originKey:e.publicKey,paymentMethodsResponse:e.paymentsResponse};new AdyenCheckout(t).create("dropin",{paymentMethodsConfiguration:{card:{hasHolderName:!1,holderNameRequired:!1,enableStoreDetails:!1,groupTypes:["mc","visa"],name:"Credit or debit card"}},onSubmit:(e,t)=>{0===$("#shipping-form").validator("validate").has(".has-error").length&&$.ajax({type:"POST",url:"/adyen/checkout_action",data:{shipEmail:$("#shipEmail").val(),shipFirstname:$("#shipFirstname").val(),shipLastname:$("#shipLastname").val(),shipAddr1:$("#shipAddr1").val(),shipAddr2:$("#shipAddr2").val(),shipCountry:$("#shipCountry").val(),shipState:$("#shipState").val(),shipPostcode:$("#shipPostcode").val(),shipPhoneNumber:$("#shipPhoneNumber").val(),payment:JSON.stringify(e.data.paymentMethod)}}).done(e=>{window.location="/payment/"+e.paymentId}).fail(e=>{console.log("Response",e),showNotification("Failed to complete transaction","danger",!0)})}}).mount("#adyen-dropin")}).fail(function(e){showNotification(e.responseJSON.message,"danger")})}); function showNotification(e,t,a,i){a=a||!1,i=i||null,$("#notify_message").removeClass(),$("#notify_message").addClass("alert-"+t),$("#notify_message").html(e),$("#notify_message").slideDown(600).delay(2500).slideUp(600,function(){i&&(window.location=i),!0===a&&location.reload()})}function slugify(e){return $.trim(e).replace(/[^a-z0-9-æøå]/gi,"-").replace(/-+/g,"-").replace(/^-|-$/g,"").replace(/æ/gi,"ae").replace(/ø/gi,"oe").replace(/å/gi,"a").toLowerCase()}$(document).ready(function(){$("#stripeButton").validator().on("click",function(e){(e.preventDefault(),0===$("#shipping-form").validator("validate").has(".has-error").length)&&window.StripeCheckout.configure({key:$("#stripeButton").data("key"),image:$("#stripeButton").data("image"),locale:"auto",token:function(e){$("#stripeButton").data("subscription")&&$("#shipping-form").append('<input type="hidden" name="stripePlan" value="'+$("#stripeButton").data("subscription")+'" />'),$("#shipping-form").append('<input type="hidden" name="stripeToken" value="'+e.id+'" />'),$("#shipping-form").submit()}}).open({email:$("#stripeButton").data("email"),name:$("#stripeButton").data("name"),description:$("#stripeButton").data("description"),zipCode:$("#stripeButton").data("zipCode"),amount:$("#stripeButton").data("amount"),currency:$("#stripeButton").data("currency"),subscription:$("#stripeButton").data("subscription")})}),$("#adyen-dropin").length>0&&$.ajax({method:"POST",url:"/adyen/setup"}).done(function(e){const t={locale:"en-AU",environment:e.environment.toLowerCase(),originKey:e.publicKey,paymentMethodsResponse:e.paymentsResponse};new AdyenCheckout(t).create("dropin",{paymentMethodsConfiguration:{card:{hasHolderName:!1,holderNameRequired:!1,enableStoreDetails:!1,groupTypes:["mc","visa"],name:"Credit or debit card"}},onSubmit:(e,t)=>{0===$("#shipping-form").validator("validate").has(".has-error").length&&$.ajax({type:"POST",url:"/adyen/checkout_action",data:{shipEmail:$("#shipEmail").val(),shipCompany:$("#shipCompany").val(),shipFirstname:$("#shipFirstname").val(),shipLastname:$("#shipLastname").val(),shipAddr1:$("#shipAddr1").val(),shipAddr2:$("#shipAddr2").val(),shipCountry:$("#shipCountry").val(),shipState:$("#shipState").val(),shipPostcode:$("#shipPostcode").val(),shipPhoneNumber:$("#shipPhoneNumber").val(),payment:JSON.stringify(e.data.paymentMethod)}}).done(e=>{window.location="/payment/"+e.paymentId}).fail(e=>{console.log("Response",e),showNotification("Failed to complete transaction","danger",!0)})}}).mount("#adyen-dropin")}).fail(function(e){showNotification(e.responseJSON.message,"danger")})});

View File

@ -162,6 +162,7 @@ $(document).ready(function (){
url: route, url: route,
data: { data: {
email: $('#shipEmail').val(), email: $('#shipEmail').val(),
company: $('#shipCompany').val(),
firstName: $('#shipFirstname').val(), firstName: $('#shipFirstname').val(),
lastName: $('#shipLastname').val(), lastName: $('#shipLastname').val(),
address1: $('#shipAddr1').val(), address1: $('#shipAddr1').val(),

File diff suppressed because one or more lines are too long

View File

@ -20,6 +20,7 @@ router.post('/customer/create', async (req, res) => {
const customerObj = { const customerObj = {
email: req.body.email, email: req.body.email,
company: req.body.company,
firstName: req.body.firstName, firstName: req.body.firstName,
lastName: req.body.lastName, lastName: req.body.lastName,
address1: req.body.address1, address1: req.body.address1,
@ -58,6 +59,7 @@ router.post('/customer/create', async (req, res) => {
// Set the customer into the session // Set the customer into the session
req.session.customerPresent = true; req.session.customerPresent = true;
req.session.customerEmail = customerReturn.email; req.session.customerEmail = customerReturn.email;
req.session.customerCompany = customerReturn.company;
req.session.customerFirstname = customerReturn.firstName; req.session.customerFirstname = customerReturn.firstName;
req.session.customerLastname = customerReturn.lastName; req.session.customerLastname = customerReturn.lastName;
req.session.customerAddress1 = customerReturn.address1; req.session.customerAddress1 = customerReturn.address1;
@ -82,6 +84,7 @@ router.post('/customer/create', async (req, res) => {
router.post('/customer/save', async (req, res) => { router.post('/customer/save', async (req, res) => {
const customerObj = { const customerObj = {
email: req.body.email, email: req.body.email,
company: req.body.company,
firstName: req.body.firstName, firstName: req.body.firstName,
lastName: req.body.lastName, lastName: req.body.lastName,
address1: req.body.address1, address1: req.body.address1,
@ -101,6 +104,7 @@ router.post('/customer/save', async (req, res) => {
// Set the customer into the session // Set the customer into the session
req.session.customerPresent = true; req.session.customerPresent = true;
req.session.customerEmail = customerObj.email; req.session.customerEmail = customerObj.email;
req.session.customerCompany = customerObj.company;
req.session.customerFirstname = customerObj.firstName; req.session.customerFirstname = customerObj.firstName;
req.session.customerLastname = customerObj.lastName; req.session.customerLastname = customerObj.lastName;
req.session.customerAddress1 = customerObj.address1; req.session.customerAddress1 = customerObj.address1;
@ -295,6 +299,7 @@ router.post('/admin/customer/lookup', restrict, async (req, res, next) => {
if(customer){ if(customer){
req.session.customerPresent = true; req.session.customerPresent = true;
req.session.customerEmail = customer.email; req.session.customerEmail = customer.email;
req.session.customerCompany = customer.company;
req.session.customerFirstname = customer.firstName; req.session.customerFirstname = customer.firstName;
req.session.customerLastname = customer.lastName; req.session.customerLastname = customer.lastName;
req.session.customerAddress1 = customer.address1; req.session.customerAddress1 = customer.address1;
@ -340,6 +345,7 @@ router.post('/customer/login_action', async (req, res) => {
// Customer login successful // Customer login successful
req.session.customerPresent = true; req.session.customerPresent = true;
req.session.customerEmail = customer.email; req.session.customerEmail = customer.email;
req.session.customerCompany = customer.company;
req.session.customerFirstname = customer.firstName; req.session.customerFirstname = customer.firstName;
req.session.customerLastname = customer.lastName; req.session.customerLastname = customer.lastName;
req.session.customerAddress1 = customer.address1; req.session.customerAddress1 = customer.address1;

View File

@ -81,6 +81,7 @@ router.post('/checkout_action', async (req, res, next) => {
orderItemCount: req.session.totalCartItems, orderItemCount: req.session.totalCartItems,
orderProductCount: req.session.totalCartProducts, orderProductCount: req.session.totalCartProducts,
orderEmail: req.session.customerEmail, orderEmail: req.session.customerEmail,
orderCompany: req.session.customerCompany,
orderFirstname: req.session.customerFirstname, orderFirstname: req.session.customerFirstname,
orderLastname: req.session.customerLastname, orderLastname: req.session.customerLastname,
orderAddr1: req.session.customerAddress1, orderAddr1: req.session.customerAddress1,

View File

@ -64,6 +64,7 @@ router.post('/checkout_action', (req, res, next) => {
orderItemCount: req.session.totalCartItems, orderItemCount: req.session.totalCartItems,
orderProductCount: req.session.totalCartProducts, orderProductCount: req.session.totalCartProducts,
orderEmail: req.session.customerEmail, orderEmail: req.session.customerEmail,
orderCompany: req.session.customerCompany,
orderFirstname: req.session.customerFirstname, orderFirstname: req.session.customerFirstname,
orderLastname: req.session.customerLastname, orderLastname: req.session.customerLastname,
orderAddr1: req.session.customerAddress1, orderAddr1: req.session.customerAddress1,

View File

@ -18,6 +18,7 @@ router.post('/checkout_action', async (req, res, next) => {
orderItemCount: req.session.totalCartItems, orderItemCount: req.session.totalCartItems,
orderProductCount: req.session.totalCartProducts, orderProductCount: req.session.totalCartProducts,
orderEmail: req.session.customerEmail, orderEmail: req.session.customerEmail,
orderCompany: req.session.customerCompany,
orderFirstname: req.session.customerFirstname, orderFirstname: req.session.customerFirstname,
orderLastname: req.session.customerLastname, orderLastname: req.session.customerLastname,
orderAddr1: req.session.customerAddress1, orderAddr1: req.session.customerAddress1,

View File

@ -166,6 +166,7 @@ router.post('/checkout_action', (req, res, next) => {
orderItemCount: req.session.totalCartItems, orderItemCount: req.session.totalCartItems,
orderProductCount: req.session.totalCartProducts, orderProductCount: req.session.totalCartProducts,
orderEmail: req.session.customerEmail, orderEmail: req.session.customerEmail,
orderCompany: req.session.customerCompany,
orderFirstname: req.session.customerFirstname, orderFirstname: req.session.customerFirstname,
orderLastname: req.session.customerLastname, orderLastname: req.session.customerLastname,
orderAddr1: req.session.customerAddress1, orderAddr1: req.session.customerAddress1,

View File

@ -57,6 +57,7 @@ router.post('/checkout_action', (req, res, next) => {
orderItemCount: req.session.totalCartItems, orderItemCount: req.session.totalCartItems,
orderProductCount: req.session.totalCartProducts, orderProductCount: req.session.totalCartProducts,
orderEmail: req.session.customerEmail, orderEmail: req.session.customerEmail,
orderCompany: req.session.customerCompany,
orderFirstname: req.session.customerFirstname, orderFirstname: req.session.customerFirstname,
orderLastname: req.session.customerLastname, orderLastname: req.session.customerLastname,
orderAddr1: req.session.customerAddress1, orderAddr1: req.session.customerAddress1,
@ -234,6 +235,7 @@ router.post('/checkout_action_subscription', async (req, res, next) => {
orderItemCount: req.session.totalCartItems, orderItemCount: req.session.totalCartItems,
orderProductCount: req.session.totalCartProducts, orderProductCount: req.session.totalCartProducts,
orderEmail: req.session.customerEmail, orderEmail: req.session.customerEmail,
orderCompany: req.session.customerCompany,
orderFirstname: req.session.customerFirstname, orderFirstname: req.session.customerFirstname,
orderLastname: req.session.customerLastname, orderLastname: req.session.customerLastname,
orderAddr1: req.session.customerAddress1, orderAddr1: req.session.customerAddress1,

View File

@ -11,6 +11,7 @@ test.before(async () => {
test('[Success] Create a customer', async t => { test('[Success] Create a customer', async t => {
const customer = { const customer = {
email: 'sarah.jones@test.com', email: 'sarah.jones@test.com',
company: 'Acme Co',
firstName: 'Sarah', firstName: 'Sarah',
lastName: 'Jones', lastName: 'Jones',
address1: '1 Sydney Street', address1: '1 Sydney Street',
@ -34,6 +35,7 @@ test('[Success] Create a customer', async t => {
test('[Fail] Try create a duplicate customer', async t => { test('[Fail] Try create a duplicate customer', async t => {
const customer = { const customer = {
email: 'sarah.jones@test.com', email: 'sarah.jones@test.com',
company: 'Acme Co',
firstName: 'Sarah', firstName: 'Sarah',
lastName: 'Jones', lastName: 'Jones',
address1: '1 Sydney Street', address1: '1 Sydney Street',
@ -56,6 +58,7 @@ test('[Fail] Try create a duplicate customer', async t => {
test('[Fail] Create with invalid email address', async t => { test('[Fail] Create with invalid email address', async t => {
const customer = { const customer = {
email: 'sarah.jones@test', email: 'sarah.jones@test',
company: 'Acme Co',
firstName: 'Sarah', firstName: 'Sarah',
lastName: 'Jones', lastName: 'Jones',
address1: '1 Sydney Street', address1: '1 Sydney Street',

View File

@ -35,6 +35,7 @@
<li class="list-group-item"><strong> {{ @root.__ "Order shipping amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount result.orderShipping}}</span></li> <li class="list-group-item"><strong> {{ @root.__ "Order shipping amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount result.orderShipping}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Order total amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount result.orderTotal}}</span></li> <li class="list-group-item"><strong> {{ @root.__ "Order total amount" }}: </strong><span class="float-right">{{currencySymbol config.currencySymbol}}{{formatAmount result.orderTotal}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Email address" }}: </strong><span class="float-right">{{result.orderEmail}}</span></li> <li class="list-group-item"><strong> {{ @root.__ "Email address" }}: </strong><span class="float-right">{{result.orderEmail}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Company" }}: </strong><span class="float-right">{{result.orderCompany}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "First name" }}: </strong><span class="float-right">{{result.orderFirstname}}</span></li> <li class="list-group-item"><strong> {{ @root.__ "First name" }}: </strong><span class="float-right">{{result.orderFirstname}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Last name" }}: </strong><span class="float-right">{{result.orderLastname}}</span></li> <li class="list-group-item"><strong> {{ @root.__ "Last name" }}: </strong><span class="float-right">{{result.orderLastname}}</span></li>
<li class="list-group-item"><strong> {{ @root.__ "Address 1" }}: </strong><span class="float-right">{{result.orderAddr1}}</span></li> <li class="list-group-item"><strong> {{ @root.__ "Address 1" }}: </strong><span class="float-right">{{result.orderAddr1}}</span></li>

View File

@ -10,6 +10,7 @@
function responseHandler(data){ function responseHandler(data){
// Set fields from the form // Set fields from the form
data.shipEmail = $('#shipEmail').val(); data.shipEmail = $('#shipEmail').val();
data.shipCompany = $('#shipCompany').val();
data.shipFirstname = $('#shipFirstname').val(); data.shipFirstname = $('#shipFirstname').val();
data.shipLastname = $('#shipLastname').val(); data.shipLastname = $('#shipLastname').val();
data.shipAddr1 = $('#shipAddr1').val(); data.shipAddr1 = $('#shipAddr1').val();

View File

@ -7,6 +7,11 @@
</div> </div>
</div> </div>
</div> </div>
<div class="col-sm-12 col-md-12">
<div class="form-group">
<input type="text" class="form-control customerDetails" id="shipCompany" name="shipCompany" placeholder="Company name" value="{{@root.session.customerCompany}}">
</div>
</div>
<div class="col-sm-12 col-md-6"> <div class="col-sm-12 col-md-6">
<div class="form-group"> <div class="form-group">
<input type="text" class="form-control customerDetails" id="shipFirstname" name="shipFirstname" placeholder="First name" value="{{@root.session.customerFirstname}}" required> <input type="text" class="form-control customerDetails" id="shipFirstname" name="shipFirstname" placeholder="First name" value="{{@root.session.customerFirstname}}" required>