As its need to set up Artification Js file through Magento Admin settings, provided by Artifi Labs along with web site id and web api client key, this helps Magento to talk with Artifi Engine.
Artifi module includes the Artifi js file and thus enables to make direct calls to Artifi Engine.
Through each call to Artifi engine, Magento sends some parameters to Artifi Engine by which Artifi Engine precede its functionality and send data back to Magento accordingly.
As per requirements, we need to make calls on following states to Artifi Engine through Magento:
- Personalization
- Editing Personalized product
- Preview personalized product
- Update product details after checkout
Product Personalization Call
Initial call to personalize any product through Artifi Engine:
Artifi.Initialize(productCode, websiteId, userId, divId, webApiclientKey, isGuest, width, height, designId, sku, extraQueryString, cartQueryString)
- sku_call – product sku ( in case of configurable product, its configurable product’s sku)
- website_id – website id set from Admin settings provided by Artifi engine
- userId_call – User / customer Id (in case of guest, guest session id)
- flag_call – true / false (Guest / Not a Guest)
- containerId – Id for container (div) where Artifi Product will be load.
- designId_call – design Id (if personalized product is in editing mode)
- webApiclientKey – web api client key set from Admin settings provided by Artifi engine.
- child_sku – child’s product’s sku (in case of configurable product)
- height – Height of Container
- width – Width of container
Product Preview Call
Call to preview personalized product:
Artifi.PreviewPopUp(productCode, websiteId, userId, isGuest, width, height, designId, sku, webApiclientKey, extraQueryString, cartQueryString)
Parameters same as mentioned in Artifi.Initialize call.
Checkout Success Call
On checkout success for any order :
Artifi.UpdateMultipleCustomizedProductOrderStatus(customizedProductIds, websiteId, successCallback, errorCallback
- customizedProductIds – All Artifi products designs related to successful order placed.
- websiteId - website id set from Admin settings provided by Artifi engine
- successCallback – success callback from Artifi engine
- errorCallback – error callback from Artifi engine
Update Customer / UserID to Artifi engine
Artifi.UpdateUserId(newUserId, oldUserId, IsGuest, websiteId, successCallback, errorCallback)
- newUserId – New user id to update
- oldUserId – Old user id which was used or to replace
- IsGuest – true or false (is guest / not a guest)
- websiteId - website id set from Admin settings provided by Artifi engine
- successCallback – success callback from Artifi engine
- errorCallback – error callback from Artifi engine
Modified Files
If you are facing below error in Magento 2.3 then you can completely replace the new Artifi Magento Connector either replace the code from below modified file.
Edit personalized designed from the cart - Not working, getting some JS error (Cannot read property 'call' of undefined jquery validate).
app\code\Artifi\Personalize\view\frontend\web\js button.js - below are the modified code _create: function() { abstractWidget.prototype._create.call(this); var addToCartForm = $(this.element).closest('form'); this._subscribe(this.element, 'click', function (e) { var formData = {}; if (addToCartForm.length) { // var cartCheck used for checking cart page to avoid form validation var cartCheck = $("#cart_page").attr("href"); if(cartCheck != "#cart"){ // Validate form data entry if (!addToCartForm.valid()) { return false; } } formData = addToCartForm.serialize(); } this._renderEditorHtml(formData, this._displayPopup.bind(this)); return false; }.bind(this)); }, app\code\Artifi\Personalize\view\frontend\templates\cart\item\renderer\actions personalize.phtml