我需要改变woocommerce的工作方式,这样它不是以标准的方式获得产品价格,而是通过API获得我提供给它的价格。
要做到这一点,我需要知道代码/函数在哪里获取定价数据。
这是因为公司有一个离线系统,它将连接到在线系统以动态提供价格(因为公司对每种产品都有5种不同的价格,这取决于存储在离线数据库中的客户)。
发布于 2015-12-10 20:42:29
价格钩
使用woocommerce_get_price挂钩返回您的自定义价格值。
add_filter('woocommerce_get_price', 'return_custom_price', 10, 2);
检查产品对象,该对象被注入为可调用函数的第二个依赖项。
function return_custom_price($price, $prod_obj) {
发布于 2015-12-10 16:45:56
基本价格是简单的后元。
$price = get_post_meta( get_the_ID(), '_regular_price', true);售价,只是一个不同的元钥匙。我想是:
$sale = get_post_meta( get_the_ID(), '_sale_price', true);也可以使用
get_sale_price( ) //returns the product's sale price.
get_regular_price( ) //Returns the product's regular price.https://stackoverflow.com/questions/34207069
复制相似问题