Support

Account

Home Forums General Issues Sum up prices by selecting (interface)?

Helping

Sum up prices by selecting (interface)?

  • Hey Guys,

    I have a wordpress shop in which I use ACF to save the prices. It is a price comparison shop. So, There are multiple prices for each product.

    I want to add the methods of payments and the fees those methods of payments can cost. I think it is the most clever to show the methods of payments and then add the fees to the price for each shop.

    My question now is, if it is possible to add numbers to displayed price?
    Because I want to overwrite the output which is shown by ACF. I do not want to save the different prices for each product and methods of payments in the database. I just want to sum them up. The product price for the product + the selected method of payment fees.

    How can I do that?

    Because I also need an interface where the user can select the methods of payments!

    Greetings and Thank You!

  • Hi @frazecolder

    You could create a text field in your backend to hold the sum of prices which would get populated dynamically and then post this value on the frontend.

    You can make use of the acf/load_field filter like so:

    <?php
    
    function my_acf_load_field( $field ) {
    	
        //get the value of the price field
        $value = $_POST['acf']['field_key'];
        $fee = '20';
        $sum = $value+$fee;
        $field['value'] = $sum;
    
        return $field;
        
    }
    
    // name
    add_filter('acf/load_field/name=my_select', 'my_acf_load_field');
    
    ?>
Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Sum up prices by selecting (interface)?’ is closed to new replies.