Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • For what it’s worth I think the developer is based in Italy, and if that’s true with what the Italians have been dealing with for the past month or two I’m not surprised there are no responses. I’d be really disappointed if this product died, it’s pretty well built.

    I ran into the same issue after a recent wordpress update. There’s a fairly easy workaround as well as an easy fix for this.

    To work around the issue you can assign calculators to products from the calculator properties page (edit the calculator, about 2/3 down the page you can assign it to products).

    The issue is in the postPage.js file in /wp-content/plugins/woo-price-calculator/admin/resources/assets/js/

    It is using an old version of ajax syntax that uses $ for ajax calls instead of jQuery.

    Here’s the revised text of the postPage.js file with the fixes applied, there’s 6 or 8 $ that need to be replaced with jQquery:

    /* New JS Code Standard */

    jQuery(document).ready(function($){

    $(‘.attach_calculator’).on(‘click’, function (e) {

    var availableCalculators = JSON.parse($(‘#availableCalculators’).val());

    var productId = $(‘#productId’).val();
    var simulatorId = $(‘#calculator’).val();

    //check if the user has selected a calculator
    if (simulatorId == ”) {
    //do nothing
    }else {
    var productsIds = JSON.parse(availableCalculators[simulatorId].products);
    attachSimulator(productId, simulatorId, productsIds);
    }

    });

    $(‘.remove_calculator’).on(‘click’, function (e) {

    var productIdToRemove = $(‘#productId’).val();
    removeSimulator(productIdToRemove);

    });

    });

    /**
    * param productId, the id of the product that the user is attaching a calculator
    * param simulatorId, the calculator id to be assigned to the product
    * param productsIds, the list of products id of the new calculator
    *
    * return void
    * */
    function attachSimulator(productId, simulatorId, productsIds) {

    requestAjaxCalculatePrice = jQuery.ajax({
    method: “POST”,
    async: this.asyncAjaxCalculatePrice,
    url: jQuery(‘#ajaxUrl’).val()+ “?action=awspricecalculator_ajax_attach_calculator” + “&id=” + productId + “&simulatorid=” + simulatorId ,
    dataType: ‘json’,
    data: {‘selectedCalculatorProducts’: productsIds},

    success: function(result, status, xhrRequest) {

    //pass the available calculators to the hidden field
    jQuery(‘#availableCalculators’).val(JSON.stringify(result));

    //dynamically change the name of the assigned calculator
    jQuery(‘#selected_calculator’).text(result[simulatorId].name);

    //show the remove calculator button
    jQuery(‘.remove_calculator’).show();

    },
    error: function(xhrRequest, status, errorMessage) {

    }
    });

    }

    /**
    * param productId, the id of the product that the user removing the calculator
    * return void
    * */
    function removeSimulator(productId) {

    requestAjaxCalculatePrice = jQuery.ajax({
    method: “POST”,
    async: this.asyncAjaxCalculatePrice,
    url: jQuery(‘#ajaxUrl’).val()+ “?action=awspricecalculator_ajax_remove_calculator” + “&id=” + productId ,
    dataType: ‘json’,
    data: {},

    success: function(result, status, xhrRequest) {

    //remove the calculator name from the selected one place
    jQuery(‘#selected_calculator’).text(”);

    //hide the remove calculator button
    jQuery(‘.remove_calculator’).hide();

    //pass the available calculators to the hidden field
    jQuery(‘#availableCalculators’).val(JSON.stringify(result));

    },
    error: function(xhrRequest, status, errorMessage) {

    }
    });

    }

Viewing 2 replies - 1 through 2 (of 2 total)