Total : 0.00 €

Before contacting us, please make sure to check our F.A.Q

Please, login or register to our website in order to be able to post a presale question in the forum.

× WooPrice Calculator PRO

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

More
8 months 3 weeks ago #2049 by bill
bill replied the topic: Format price (start from xx $) in category page
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

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago - 8 months 4 weeks ago #2046 by Dario Poma
Dario Poma replied the topic: Format price (start from xx $) in category page

bill wrote: Hi Dario ,
yes that is possible too. Here is the link to our documentation site: altoswebsolutions.com/manual/woo-price-c...ced-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


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 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?
Last Edit: 8 months 4 weeks ago by Dario Poma.

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #2045 by bill
bill replied the topic: Format price (start from xx $) in category page
Hi Dario ,

yes that is possible too. Here is the link to our documentation site: altoswebsolutions.com/manual/woo-price-c...ced-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

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #2041 by Dario Poma
Dario Poma replied the topic: Format price (start from xx $) in category page
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

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #2040 by bill
bill replied the topic: Format price (start from xx $) in category page
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

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #2039 by Dario Poma
Dario Poma replied the topic: Format price (start from xx $) in category page
Can you help me?

Thank you!

Please Log in or Create an account to join the conversation.

More
9 months 21 hours ago #2032 by Dario Poma
Dario Poma replied the topic: Format price (start from xx $) in category page
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

Please Log in or Create an account to join the conversation.

More
9 months 3 days ago #2029 by bill
bill replied the topic: Format price (start from xx $) in category page
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->calculatorHelper->get_simulator_for_product({id of the product});

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

Waiting for your feedback
Kind Regards,
Bill

Please Log in or Create an account to join the conversation.

More
9 months 3 days ago #2025 by Dario Poma
Dario Poma created the topic: Format price (start from xx $) in category page
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!

Please Log in or Create an account to join the conversation.

Moderators: david
Time to create page: 0.183 seconds

Cart

Total : 0.00 €