Language: JavaScript
Label: safe
CWE: CWE-829 \u2014 Inclusion of Functionality from Untrusted Control Sphere
The product imports, requires, or includes executable functionality (such as a library) from a source that is outside of the intended control sphere.

Code:
function setVariationPrice() {

    var purchasePrice = $("#productVariationPurchasePriceSetter").val();
    var salePrice = $("#productVariationSelePriceSetter").val();
    var discount = $("#productVariationDiscountSetter").val();

    // Set prces for specific units
    var getWhereUnit = $("#SetPricesWhereUnit").val();
    if( getWhereUnit !== "" ) {
        
        $.each($(`input[name='product_variation[Units][]'][value='${getWhereUnit}'], select[name='product_variation[Units][]'] option:selected[value='${getWhereUnit}']`), function(key, val) {
            
            /** Set purchase price */
            if(purchasePrice !== "") {
                $(this).closest("li").find(".productVariationPurchasePrice").val(purchasePrice)
            }

            /** Set sale Price */
            if(salePrice !== "") {
                $(this).closest("li").find(".productVariationSalePrice").val(salePrice)
            }

            /** Set discount */
            if(discount !== "") {
                $(this).closest("li").find(".productVariationDiscount").val(discount)
            }

        });

    } else {

        /** Set purchase price */
        if(purchasePrice !== "") {
            $(".productVariationPurchasePrice").val(purchasePrice)
        }

        /** Set sale Price */
        if(salePrice !== "") {
            $(".productVariationSalePrice").val(salePrice)
        }

        /** Set discount */
        if(discount !== "") {
            $(".productVariationDiscount").val(discount)
        }

    }

}