本文整理汇总了PHP中Receipt::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Receipt::add方法的具体用法?PHP Receipt::add怎么用?PHP Receipt::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Receipt
的用法示例。
在下文中一共展示了Receipt::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: list_import_product_to_json_data
public function list_import_product_to_json_data($data)
{
//new a new receipt
//basically, a Reiceipt is a list of product...
$receipt = new Receipt();
foreach ($data as $value) {
//new Product
$product = new ImportProduct($value['Import_Price']);
// add attribute to it
$product->add_attribute($value['Name'], new Unit($value['UnitName'], $value['Price']), $value['Id'], $value['ProductId']);
//add the product to the receipt
$receipt->add($product);
}
// return the receipt in json format
return $receipt->json_encode();
}
示例2: push_new_product_data_to_server
function push_new_product_data_to_server($array)
{
if (sizeof($array) == 0) {
return;
}
$receipt = new Receipt();
foreach ($array as $key => $product) {
if (isset($product['name'])) {
$import_product = new ImportProduct($product['bought']);
$import_product->add_attribute($product['name'], new Unit($product['unit_name'], $product['sale']));
$receipt->add($import_product);
}
}
echo $receipt->json_encode(true);
$manage = new Management();
$manage->push_new_product_data_to_server($receipt);
}