如何将运费与产品实际价格相加? [英] how to add shipping cost with product actual price?

查看:30
本文介绍了如何将运费与产品实际价格相加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的电子商务网站使用的是 woocommerce 插件 v2.2.8.我正在使用基于重量的运输方式.是否有可能在产品页面中显示的产品实际价格中添加运费?

I am using woocommerce plugin v2.2.8 for my eCommerce site. I am using weight based shipping method. Is there is any possibility to add shipping cost with products actual price which is displaying in product page?

例如,Product1 = Rs 800/- &该产品的运费为 50 卢比/-商店页面中的产品 1 价格应显示为 850 卢比/-(实际价格 + 运费) 注意:运费是根据基于重量的运输方式计算的.这可能吗?

For Eg.. Product1 = Rs 800/- & shipping cost of this product is Rs 50/- Product1 price in shop page should be displayed as Rs 850/- (Actual price + shipping cost) Note: shipping cost calculated from weight based shipping method. Is this possible?

对此有什么想法吗???

Any idea regarding this???

推荐答案

送货总是需要一个目的地地址,但是当您在商店页面中展示产品时,那里没有可用的地址.但是,由于您可以为每个区域设置统一运费设置,因此您可以自行检索该值并将该价格添加到产品中.如果您需要基于产品的运输价格,请定义运输类别,为产品分配所需的运输类别并为每个运输类别配置价格.

Shipping always needs a destination address, but when you are showing a product in shop page then no address is available there. But, as you can have a flat rate shipping setting for every zone then you can retrieve that value by your own and add that price to product. If you need product based shipping price, define shipping classes, assign desired shipping class to product and configure prices for each shipping class.

现在在前端显示产品价格时,您可以使用以下 woocommerce hook 并放置您的逻辑来修改价格.

Now while showing price for product in front end you can use following woocommerce hook and put your logic to modify the price.

function return_custom_price($price, $product) {
    //Apply your logic and modify the price
    return $price;
}
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);

这篇关于如何将运费与产品实际价格相加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆