$discountData_1 = new DiscountRule(); $discountData_1->contains('A')->contains('B')->set(10); $discountData_2 = new DiscountRule(); $discountData_2->contains('D')->contains('E')->set(5); $discountData_3 = new DiscountRule(); $discountData_3->contains('E')->contains('F')->contains('G')->set(5); $discountData_4 = new DiscountRule(); $discountData_4->contains('A')->option('K')->option('L')->option('M')->set(5); $discountData_5 = new DiscountRule(); $discountData_5->setByAmount(3, 5)->setByAmount(4, 10)->setByAmount(5, 20)->not('A')->not('C'); //Список товаров $products = []; $products[] = ['type' => 'A', 'price' => 1000]; $products[] = ['type' => 'A', 'price' => 1000]; $products[] = ['type' => 'B', 'price' => 1000]; $products[] = ['type' => 'C', 'price' => 1000]; $products[] = ['type' => 'D', 'price' => 1000]; $products[] = ['type' => 'E', 'price' => 1000]; $products[] = ['type' => 'E', 'price' => 1000]; $products[] = ['type' => 'F', 'price' => 1000]; $products[] = ['type' => 'G', 'price' => 1000]; $products[] = ['type' => 'H', 'price' => 1000]; $products[] = ['type' => 'I', 'price' => 1000]; $products[] = ['type' => 'J', 'price' => 1000]; $products[] = ['type' => 'K', 'price' => 1000]; $products[] = ['type' => 'L', 'price' => 1000]; $products[] = ['type' => 'M', 'price' => 1000]; // Считаем итоговую сумму $manager = new DiscountManager(); $manager->apply($products, [$discountData_1, $discountData_2, $discountData_3, $discountData_4, $discountData_5]); echo 'Final price: ' . $manager->final_price;
private function calculateMarkupPrice($price) { return DiscountManager::calculateHotelPrice($price); }
/** * @return float price */ public function getPrice() { //return $this->markupPrice; return DiscountManager::calculateHotelPrice($this->rubPrice); }