if ($item->printSettings->paperSize == paperSize::$A4) { echo 'selected'; } ?> >A4</option> <option value="B4" <?php if ($item->printSettings->paperSize == paperSize::$B4) { echo 'selected'; } ?> >B4</option> </select> </td> <td role="single-price" > <span class="single" data-role="single-price"><?php $price = $item->get_price_per_copy() / 100; echo $price; ?> </span> </td> <td role="copies"> <button class="plus" data-role="copies-btn"></button><input class="pages" readonly type="text" value="<?php echo $item->printSettings->amount; ?> "><button class="minus" data-role="copies-btn"></button> </td> <td role="gross"> <span class="gross-price" data-role="gross"><?php $subtotal = $price * $item->printSettings->amount; echo $subtotal; $total = $total + $subtotal;
/** * 更改打印设定 * 返回单价 */ public function changePrintSetting($fileMD5, $option, $optionValue) { //找到item $items = $this->getItems(); $key = 0; foreach ($items as $one) { if ($one->fileMD5 == $fileMD5) { $isIn = true; break; } $key++; } switch ($option) { case 'paperSize': if (in_array($optionValue, paperSize::getPaperSize())) { $items[$key]->printSettings->paperSize = $optionValue; } break; case 'TwoSides': if ($optionValue == 'double') { $optionValue = true; } else { $optionValue = false; } //echo $optionValue; //if (in_array($optionValue,array(true,false))) { $items[$key]->printSettings->isTwoSides = $optionValue; //} break; case 'pptPerPage': $optionValue = intval($optionValue); if (in_array($optionValue, pptPerPage::getPptPerPage())) { $items[$key]->printSettings->pptPerPage = $optionValue; } break; case 'amount': $optionValue = intval($optionValue); if ($optionValue > 0) { $items[$key]->printSettings->amount = $optionValue; } break; case 'direction': if (in_array($optionValue, printDirection::getPrintDirection())) { $items[$key]->printSettings->direction = $optionValue; } break; default: break; } $newItem = new MY_Item($items[$key]->filename, $items[$key]->fileMD5); $newItem->printSettings = $items[$key]->printSettings; //更新bmob数据,加入价格信息 try { $items[$key]->subtotal = $newItem->get_subtotal(); $items[$key]->pages = $newItem->get_pages(); $this->bmobObject->update($this->cartId, array('items' => json_encode($items))); //var_dump($items); //var_dump($this->getItems()); } catch (Exception $e) { throw new MY_Exception($e->error_msg); } //返回单价和小记 return array('unitPrice' => $newItem->get_price_per_copy() / 100, 'subtotal' => $newItem->get_price_per_copy() * $items[$key]->printSettings->amount / 100); }