Plugin Directory

Changeset 3459658


Ignore:
Timestamp:
02/12/2026 08:34:33 AM (7 days ago)
Author:
printess
Message:

Now when saving and invalid product variant options are selected, an error will appear that the current state can not ber saved due to errors

Location:
printess-editor/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • printess-editor/trunk/includes/js/printessWoocommerce.js

    r3459226 r3459658  
    531531        let ret = null;
    532532        const attributeLookup = getAttributeLookup(product, true);
    533         const variantSpecificValues = [];
    534533        const attributeValuesUsedInVariants = {};
    535534        if (product.variants) {
     
    548547            });
    549548        }
    550         const mapValue = (name, value) => {
    551             let mappedValue = value;
    552             let attribute = null;
    553             if (attributeLookup[name]) {
    554                 attribute = attributeLookup[name];
    555             }
    556             if (!attribute) {
    557                 for (const key in attributeLookup) {
    558                     if (attributeLookup.hasOwnProperty(key)) {
    559                         if (attributeLookup[key].name === key || attributeLookup[key].key === key) {
    560                             attribute = attributeLookup[key];
    561                             break;
    562                         }
    563                     }
    564                 }
    565                 if (attribute && attribute.valueKeys && attribute.valueKeys.length > 0) {
    566                     for (let i = 0; i < attribute.values.length; ++i) {
    567                         if (attribute.values[i] === value && attribute.valueKeys.length > i) {
    568                             mappedValue = attribute.valueKeys[i];
    569                             break;
    570                         }
    571                     }
    572                 }
    573             }
    574             return mappedValue;
    575         };
    576         for (const name in productOptionValues) {
    577             const value = mapValue(name, productOptionValues[name]);
    578             if (productOptionValues.hasOwnProperty(name) && attributeLookup[name] && attributeLookup[name].usedForVariants && attributeValuesUsedInVariants[attributeLookup[name].key] && attributeValuesUsedInVariants[attributeLookup[name].key][value]) {
    579                 if (!attributeLookup[name].valueKeys || attributeLookup[name].valueKeys.includes(value)) {
    580                     variantSpecificValues.push({ key: attributeLookup[name].key, value: value });
    581                 }
    582             }
    583         }
    584         if (product.variants) {
    585             let variants = product.variants;
    586             variantSpecificValues.forEach((vSv) => {
    587                 variants = variants.filter((variant) => {
    588                     return variant.attributes[vSv.key] === vSv.value;
    589                 });
    590                 if (variants.length <= 0 && !ret) {
    591                     ret = vSv.key;
    592                 }
    593             });
    594         }
    595         return ret;
     549        for (const optionName in productOptionValues) {
     550            if (productOptionValues.hasOwnProperty(optionName)) {
     551                for (const attributeName in attributeLookup) {
     552                    if (attributeLookup.hasOwnProperty(attributeName)) {
     553                        if (optionName === attributeName || optionName === attributeLookup[attributeName].key) {
     554                            if (!attributeLookup[attributeName].valueKeys.includes(productOptionValues[optionName])) {
     555                                return optionName;
     556                            }
     557                        }
     558                    }
     559                }
     560            }
     561        }
     562        return null;
    596563    };
    597564    const updatePrintessValues = function (saveToken, thumbnailUrl, designId, designName) {
     
    13201287                context.lastSaveSaveToken = saveToken;
    13211288                const productValues = getCurrentProductOptionValues(settings.product);
    1322                 const unparsedProductValues = removeAttributePrefix(getCurrentProductOptionValues(settings.product, false));
    13231289                const variant = getCurrentVariant(productValues, settings.product);
    1324                 const checkForValidVariant = getCurrentVariant(unparsedProductValues, settings.product, false);
    1325                 if (!checkForValidVariant && settings.product.variants && settings.product.variants.length > 0) {
    1326                     const invalidVariantOptionName = getInvalidVariantOption(unparsedProductValues, settings.product);
     1290                if (settings.product.variants && settings.product.variants.length > 0) {
     1291                    const invalidVariantOptionName = getInvalidVariantOption(productValues, settings.product);
    13271292                    if (invalidVariantOptionName) {
    1328                         // alert(printessSettings?.userMessages && printessSettings.userMessages["unableToSaveChangesDueToInvalidVariant"] ? printessSettings.userMessages["unableToSaveChangesDueToInvalidVariant"].replace("{0}", invalidVariantOptionName) : ("Unable to save changes due to invalid value for " + invalidVariantOptionName));
    1329                         console.warn(printessSettings?.userMessages && printessSettings.userMessages["unableToSaveChangesDueToInvalidVariant"] ? printessSettings.userMessages["unableToSaveChangesDueToInvalidVariant"].replace("{0}", invalidVariantOptionName) : ("Unable to save changes due to invalid value for " + invalidVariantOptionName));
    1330                         //return;
     1293                        let message = printessSettings?.userMessages && printessSettings.userMessages["unableToSaveChangesDueToInvalidVariant"] ? printessSettings.userMessages["unableToSaveChangesDueToInvalidVariant"].replace("{0}", invalidVariantOptionName) : ("Unable to save changes due to invalid value for " + invalidVariantOptionName);
     1294                        message += "\r\nSaveToken: " + saveToken;
     1295                        alert(message);
     1296                        console.log("Current SaveToken: " + saveToken);
     1297                        return;
    13311298                    }
    13321299                }
  • printess-editor/trunk/printess.php

    r3459226 r3459658  
    55 * Plugin URI: https://printess.com/kb/integrations/woo-commerce/index.html
    66 * Developer: Bastian Kröger ([email protected]); Alexander Oser ([email protected])
    7  * Version: 1.6.80
     7 * Version: 1.6.81
    88 * Author: Printess
    99 * Author URI: https://printess.com
     
    1414 * Tested up to: 6.9
    1515 *
    16  * Woo: 10000:924038dfsfhsf8429842386wdff234sfd
     16 * Woo: 10000:924040dfsfhsf8429842386wdff234sfd
    1717 * WC requires at least: 5.8
    1818 * WC tested up to: 10.4.3
  • printess-editor/trunk/readme.txt

    r3459226 r3459658  
    55Tested up to: 6.9
    66WC Tested up to: 10.4.3
    7 Stable tag: 1.6.80
     7Stable tag: 1.6.81
    88Requires PHP: 8.1
    99License: GPLv2 or later
     
    393393  = 1.6.80 =
    394394 - Extended debug code to test invalid page counts when saving designs on buyer side.
     395
     396  = 1.6.81 =
     397 - Now when saving and invalid product variant options are selected, an error will appear that the current state can not ber saved due to errors
     398
Note: See TracChangeset for help on using the changeset viewer.