Background:
I am trying to circumvent an issue caused by the fact that Wix-Stores does not allow to set a static “delivery address” (we do shop-only pick-up) and because of this asks every client to insert a personal address at confirmation, in order to calculate applicable tax rules - and picks up addresse already defined via wixCRM Contacts. If a client happens to have registered an address from another country, or even is using an IP address abroad, Wix-Stores interprets this to be as a need to calculate applicable VAT rules … which is nonsense, given that the settings for shipping are defined properly, as are applicable tax rules for the pick-up location. Wix Support told me that populating a static address in settings would not help - it needs to be set a customer level.
Workaround envisaged:
The workaround (not happy, but when testing it, it worked …) could be to create an additional static “c/o pick-up store” address within CRM contacts (we ask the client to confirm), for each and every one, at registration … but here is, where I got coding issues.
Coding issue:
I ask customers to first register, before doing business. For this, I first gather customer information via a separate page (works perfectly fine), then fire the below …createContact command “on click” (which does NOT work) and direct the client to a lightbox containing a Wix custom registration form, where I just reuse data in required fields and ask for a password (the registration part also works fine).
Any suggestions, please? I have run through many blogs here, but am apparently not able to reproduce the proposed solutions …
Or is it an issue that the registration overwrites data from the previously created contact??
Remark: below “short names” for field content work properly (data is reproducable via console.log). So no worries about this, either.
https://jochenimhoff.wixsite.com/test-bwi/registrierung
import wixCrm from 'wix-crm';
export function confirm_click(event) {
let emails = []
let email = $w('#confirmEMail').value
emails.push(email)
let country = $w('#land2') //value in ISO 3166 alpha-2 format (capital letters)
let anrede = $w('#anrede').value
let titel = $w('#titel').value
let vorname = $w('#Vorname').value
let nachname = $w('#Nachname').value
let addressType = "SHIPPING" //hard entry to store single pick-up address
let strasseNr = $w('#strasseNr2').value
let postleitzahl = $w('#postleitzahl2').value
let ort = $w('#ort2').value
let bundesland = $w('#bundesland2').value
let contactInfo = {
"Anrede": anrede, //custom field - written exactly like this (minor letters does not solve)
"Titel": titel, //custom field - written exactly like this (minor letters does not solve)
"firstName": vorname,
"lastName": nachname,
"emails": [emails],
"addresses": [{
"tag": addressType,
"street": strasseNr,
"city": ort,
"state": bundesland,
"country": country,
"zip": postleitzahl}]
}
wixCrm.createContact(contactInfo)
.then( (contactId) => {
} );
setTimeout (function delay () {
wixWindow.openLightbox("Custom Signup", {
"vorname": $w('#Vorname').value,
"nachname": $w('#Nachname').value,
"email": $w('#confirmEMail').value,
});3000})
$w('#success').hide()
}
I get an error message “Wix code SDK error: The url parameter that is passed to the to method cannot be set to the value . It must be of type string.”
At browser console level (am using Chrome, not IE9 …), the following is stated regarding the above error message in the corresponding code line - otherwise, I am not transferring any non-string type of information to the back-end and back to the front-end on that page:
// this fails for some browsers.
if (originalConsoleLevel) {
// IE9 doesn’t allow calling apply on console functions directly
// See: javascript - Does IE9 support console.log, and is it a real function? - Stack Overflow
Function.prototype.apply.call(originalConsoleLevel, originalConsole, args);
}
Could this be the reason for the above coding NOT creating the contact at all?