[SOLVED]Format price (start from xx $) in category page

Home – SaaS Forums Support questions WooPrice Calculator (Pro) [SOLVED]Format price (start from xx $) in category page

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #7062
    Dario Poma
    Participant

    Good morning,
    is it possible to insert a string (i.e. “start from”) before the price in category page (so that result will be “start from xx $”)?
    Is it also possible to check via PHP if the product is a “normal” simple product or is a simple product with WooPrice Calculator plugin?

    Thank you!

    #7070
    bill
    Participant

    Hello Dario,
    sorry for the delay of giving you an answer.
    Regarding your request, here is the hook that is used to get the price, and you can use it to modify the price in category price :

    add_filter( ‘awspc_filter_wc_get_price_html’ , array($this, ‘custom_awspc_filter_wc_get_price_html’) , 10 , 2 );

    function custom_awspc_filter_wc_get_price_html($price , $apiParams)

    About second question, our calculator has the function that checks if a simple product has caculator or not.
    Here is the function that makes the control:
    $hasCalculator = $GLOBALS[‘woopricecalculator’]->calculatorHelper->get_simulator_for_product({id of the product});

    if(!empty($hasCalculator)){
    //has calculator
    }

    Waiting for your feedback
    Kind Regards,
    Bill

    #7069
    Dario Poma
    Participant

    Good morning,
    I tried the function to recognize if the product has the plugin WooPrice Calculator but it does not work.
    This is the code that doesn’t work:
    add_action( 'woocommerce_before_single_product', 'test', 15 );
    function test() {
    global $product;
    $id = $product->get_id();
    $hasCalculator = $GLOBALS->calculatorHelper->get_simulator_for_product($id);

    if(!empty($hasCalculator)){
    echo 'has calculator';
    }
    }

    How can I solve?
    Is it also possible to know if there is a particular field in the product (given the ID) (e.g. aws_price_calc_1)? This is useful to know for example if you are talking about square meters or cubic meters.

    Thank you

    #7068
    Dario Poma
    Participant

    Can you help me?

    Thank you!

    #7067
    bill
    Participant

    Hello Dario,

    sorry for the first code, it is just a syntax problem the functional code will be:

    add_action( 'woocommerce_before_single_product', 'test', 15 );
    function test() {
    global $product;
    $id = $product->get_id();
    $hasCalculator = $GLOBALS['woopricecalculator']->calculatorHelper->get_simulator_for_product($id);

    if(!empty($hasCalculator)){
    echo 'has calculator';
    }else{
    echo 'has no calculator';
    }
    }

    Best regards
    Bill
    AT1030

    #7066
    Dario Poma
    Participant

    Good morning,
    Is it also possible to know if there is a particular field in the product (given the ID) (e.g. aws_price_calc_1)? This is useful to know for example if you are talking about square meters or cubic meters.

    Thank you

    #7065
    bill
    Participant

    Hi Dario ,

    yes that is possible too. Here is the link to our documentation site: https://altoswebsolutions.com/manual/woo-price-calculator/advanced-validation-rules
    You will find everything you need in that page to access and do advance validations on the input fields.

    Best regards.
    Bill
    AT1030

    #7064
    Dario Poma
    Participant

    [quote=”bill” post=2045]Hi Dario ,
    yes that is possible too. Here is the link to our documentation site: https://altoswebsolutions.com/manual/woo-price-calculator/advanced-validation-rules
    You will find everything you need in that page to access and do advance validations on the input fields.
    Best regards.
    Bill
    AT1030[/quote]

    Thank you but how can I get $params variable for example in this function?

    add_action( 'woocommerce_before_single_product', 'test', 15 );
    function test() {
    global $product;
    $id = $product->get_id();
    $hasCalculator = $GLOBALS['woopricecalculator']->calculatorHelper->get_simulator_for_product($id);

    if ( PRODUCT WITH ID $ID HAS aws_price_calc_1 FIELD) {
    echo 'yes';
    } else { echo 'no'; }
    }

    I have to use for example $width = $_REQUEST[‘aws_price_calc_1’] so I don’t need $params variable? And how can I check if the field exist (so it is present in the product) or not?

    #7063
    bill
    Participant

    Hi Dario,

    you can’t access params inside your function because you are not implementing a WPC hook but a Woocommerce one. In order to access params you must implement the hook specified in the documentation. Anyway if you want to know which are the input fields of the attached calculator to the given product using your function you can do this:

    function test() {
    global $product;
    $id = $product->get_id();
    $hasCalculator = $GLOBALS['woopricecalculator']->calculatorHelper->get_simulator_for_product($id);

    print_r($hasCalculator->fields); //outputs ["1", "2", "3"] all the input fields of this calculator has
    if(!empty($hasCalculator)){
    echo 'has calculator';
    }else{
    echo 'has no calculator';
    }
    }

    so you can loop through “$hasCalculator->fields” to get the ids of all input fields that are part of that calculator.

    Bests.
    Bill
    AT1030

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.