Language: JavaScript
Label: safe
CWE: CWE-352 \u2014 Cross-Site Request Forgery (CSRF)
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.

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)
        }

    }

}