我试图获得购物车总重量,包括重量等级表中的转换价值。
到目前为止,我的代码如下所示:
public function getOrderWeight($order_id) {
$query = $this->db->query("SELECT SUM(p.weight * op.quantity) AS weight FROM " . DB_PREFIX . "order_product op LEFT JOIN " . DB_PREFIX . "product p ON op.product_id = p.product_id WHERE op.order_id = '" . (int) $order_id . "'");
if ($query->row['weight']) {
$weight = $query->row['weight'];
} else {
$weight = 0;
$weightsuff = "";
}
return $weight;
}
这样我只能获得数据库中的权重。但是,我想使用权重类表oc_weight_class
中的权重转换来获得价格。但我还没有达到目的。
我试图在人类演讲中完成这样的事情:
get product weight from order table * quantity / weight rate value
to get everything in default weight rate (kg).