Custom prices

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #162987
    Taha
    Moderator
    Plugin Support

    Hi Pascal,

    Thanks for reaching out, and my sincere apologies for the delayed response—your message was mistakenly overlooked.

    I’ve reviewed your request and I’m currently consulting with our developer to see if there’s a way to accomplish what you’re looking for. I’ll get back to you as soon as possible with an update.

    Thank you again for your patience and understanding.

    Best regards,
    WPFactory Support Team

    #164601
    Taha
    Moderator
    Plugin Support

    Hi Pascal,

    Good morning, I hope you are doing well.


    Sorry for the delay in getting back to you — your issue was with our development team, and I have just heard back from them. Here is the suggested code for achieving your request.

    The developer has tested it using the custom_function option. Based on your description, the following code worked as expected, and you can adjust it if needed:

    function france_price_with_vat() {
        $product_id = get_the_ID();
        if ( ! $product_id ) return;
    
        $product = wc_get_product( $product_id );
        if ( ! $product ) return;
    
        // Get WooCommerce setting (if prices include tax)
        $prices_include_tax = get_option( 'woocommerce_prices_include_tax' ) === 'yes';
    
        // VAT rates
        $germany_vat = 1.19;
        $france_vat = 1.20;
    
        // Product price
        $price = floatval( $product->get_price() );
    
        if ( $prices_include_tax ) {
           // Remove Germany VAT, then apply France VAT
           $price_excl = $price / $germany_vat;
           $france_price = $price_excl * $france_vat;
        } else {
           // Add France VAT directly if price is excluding tax
           $france_price = $price * $france_vat;
        }
    
        return number_format( $france_price, 2 );
    }

    And here’s the XML structure you can use:

    <vat_price>
    <germany>[alg_product_price]</germany>
    <france>[alg_product_id custom_function="france_price_with_vat"]</france>
    </vat_price>

    Please try it out and let me know if it works for you!

    Best regards,
    WPFactory support team

    #165034
    Pascal Schmid
    Participant

    Hi Taha!

    Many thanks, sounds promising! We’ll buy  the plugin and try it out and will come back to you with a feedback 🙂

    Best regards

    Pascal

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