How can i set my custom calculated price as actual sell price to basket in Woocommerce

Hello I am calculating price on the basis of total amount. I want to add after discount price as my sell price for product. so when i click on the add to cart button it should show the after discount price.

Here’s my html sturucture that i have created accoding to my requirenment:

<div class="woocommerce-variation-price">
    <span class="price-incvat" style="text-decoration:line-through;">
        <span class="woocommerce-Price-amount amount">
            <bdi>
                <span class="woocommerce-Price-currencySymbol">£</span>
                531.36
            </bdi>
        </span> 
            Inc. VAT
        </span><br>
        <span class="price2" style="text-decoration:line-through;">
            <span class="woocommerce-Price-amount amount">
                <bdi>
                    <span class="woocommerce-Price-currencySymbol">£</span>
                    442.80
                </bdi>
            </span> 
            Exc. VAT
        </span><br>
        <span class="price-incvat newprice">
            <span class="woocommerce-Price-amount amount">
                <bdi>
                    <span class="woocommerce-Price-currencySymbol">£</span>
                    478.22
                </bdi>
            </span> 
            Inc. VAT
        </span><br>
        <span class="price2 newprice">
            <span class="woocommerce-Price-amount amount">
                <bdi>
                    <span class="woocommerce-Price-currencySymbol">£</span>
                    398.52
                </bdi>
            </span>
            Exc. VAT
        </span>
    </div>

Here’s defalut html sturucture of Woocommerce

<div class="yith_wapo_group_total
        " data-product-price="442.8" data-product-id="205692">
<table>
<tbody><tr class="ywapo_tr_product_base_price">
<td data-nosnippet="">Product price</td>
<td data-nosnippet=""><div class="yith_wapo_group_product_price_total"><span class="price amount">£442.80</span></div></td>
</tr>
<tr class="ywapo_tr_additional_options">
<td data-nosnippet="">Additional options total:</td>
<td data-nosnippet=""><div class="yith_wapo_group_option_total"><span class="price amount">£0.00</span></div></td>
</tr>
<tr class="ywapo_tr_order_totals">
<td data-nosnippet="">Order total:</td>
<td data-nosnippet=""><div class="yith_wapo_group_final_total"><span class="price amount">£442.80</span></div></td>
</tr>
</tbody></table>
</div>

And here’s my Jquery code to calculate dicosunt price:

jQuery(function ($) {
$('.yith_wapo_group_final_total .price.amount').on("DOMSubtreeModified", function () {
var price_ele = jQuery(".woocommerce-variation.single_variation .woocommerce-variation-price");
var price_ele_simp = jQuery(".new-price-simple");
var add_price1 = jQuery(".yith_wapo_group_final_total .price.amount").text().replace(/£/g, "");
var add_price = add_price1.replace(/,/g, "");
var inc = (add_price * 20) / 100;
var inc_price = parseFloat(add_price) + parseFloat(inc);
if(bundleproduct != '')
{
var bundleExcVatFinalPrice = parseFloat(add_price) - (add_price * bundleproduct);
var bundleIncVatFinalPrice = parseFloat(bundleExcVatFinalPrice) + (bundleExcVatFinalPrice * 0.20);
if (add_price1 != 0 && price_ele.text() != "") 
   {
    price_ele.html('<span class="price-incvat" style="text-decoration:line-through;"><span           class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(inc_price.toFixed(2)) + '</bdi></span> Inc. VAT</span></span><br><span class="price2" style="text-decoration:line-through;"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(add_price) + '</bdi></span> Exc. VAT</span><br><span class="price-incvat"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(bundleIncVatFinalPrice.toFixed(2)) + '</bdi></span> Inc. VAT</span></span><br><span class="price2"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(bundleExcVatFinalPrice.toFixed(2)) + '</bdi></span> Exc. VAT</span>');
   }
else if (price_ele.text() == "") 
   {
    price_ele.html('<span class="price-incvat" style="text-decoration:line-through;"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(inc_price.toFixed(2)) + '</bdi></span> Inc. VAT</span></span><br><span class="price2" style="text-decoration:line-through;"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(add_price) + '</bdi></span> Exc. VAT</span><br><span class="price-incvat"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(bundleIncVatFinalPrice.toFixed(2)) + '</bdi></span> Inc. VAT</span></span><br><span class="price2"><span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">£</span>' + numberWithCommas(bundleExcVatFinalPrice.toFixed(2)) + '</bdi></span> Exc. VAT</span>');
   }
}
}, 350);
});
});

Now What i want is.. when i click on add-to-cart button it should take span with class “price2 newprice” that is “398.52” in according to html given above.

Attched images for better understanding:
Before adding to cart

After clickeing basket button (It should show “398.52” price here

Thank You

I have tried this in above jquery i have prodvide:

$('.yith_wapo_group_total').attr('data-product-price', bundleExcVatFinalPrice);
$('.yith_wapo_group_final_total .price amount').attr('data-product-price', bundleExcVatFinalPrice);

But it’s not working. What i want is.. when i click on add-to-cart button it should take span with class “price2 newprice” that is “398.52” in according to html given above.

New contributor

Sabir is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật