public function current() { do { $order = parent::current(); $getNext = false; if ($this->rangeDate !== null && ($order[OrderTableMap::CREATED_AT] < $this->rangeDate['start'] || $order[OrderTableMap::CREATED_AT] > $this->rangeDate['end'])) { $this->next(); $getNext = true; } } while ($getNext && $this->valid()); $locale = $this->language->getLocale(); $query = OrderQuery::create()->useCurrencyQuery()->addAsColumn('currency_CODE', CurrencyTableMap::CODE)->endUse()->useCustomerQuery()->addAsColumn('customer_REF', CustomerTableMap::REF)->endUse()->useOrderProductQuery()->useOrderProductTaxQuery(null, Criteria::LEFT_JOIN)->addAsColumn('product_TAX', 'IF(' . OrderProductTableMap::WAS_IN_PROMO . ',' . 'SUM(' . OrderProductTaxTableMap::PROMO_AMOUNT . '),' . 'SUM(' . OrderProductTaxTableMap::AMOUNT . ')' . ')')->addAsColumn('tax_TITLE', OrderProductTableMap::TAX_RULE_TITLE)->endUse()->addAsColumn('product_TITLE', OrderProductTableMap::TITLE)->addAsColumn('product_PRICE', 'IF(' . OrderProductTableMap::WAS_IN_PROMO . ',' . OrderProductTableMap::PROMO_PRICE . ',' . OrderProductTableMap::PRICE . ')')->addAsColumn('product_QUANTITY', OrderProductTableMap::QUANTITY)->addAsColumn('product_WAS_IN_PROMO', OrderProductTableMap::WAS_IN_PROMO)->groupById()->endUse()->orderById()->groupById()->useOrderCouponQuery(null, Criteria::LEFT_JOIN)->addAsColumn('coupon_COUPONS', 'GROUP_CONCAT(' . OrderCouponTableMap::TITLE . ')')->groupBy(OrderCouponTableMap::ORDER_ID)->endUse()->useModuleRelatedByPaymentModuleIdQuery('payment_module')->addAsColumn('payment_module_TITLE', '`payment_module`.CODE')->endUse()->useModuleRelatedByDeliveryModuleIdQuery('delivery_module')->addAsColumn('delivery_module_TITLE', '`delivery_module`.CODE')->endUse()->useOrderAddressRelatedByDeliveryOrderAddressIdQuery('delivery_address_join')->useCustomerTitleQuery('delivery_address_customer_title_join')->useCustomerTitleI18nQuery('delivery_address_customer_title_i18n_join')->addAsColumn('delivery_address_TITLE', '`delivery_address_customer_title_i18n_join`.SHORT')->endUse()->endUse()->useCountryQuery('delivery_address_country_join')->useCountryI18nQuery('delivery_address_country_i18n_join')->addAsColumn('delivery_address_country_TITLE', '`delivery_address_country_i18n_join`.TITLE')->endUse()->addAsColumn('delivery_address_COMPANY', '`delivery_address_join`.COMPANY')->addAsColumn('delivery_address_FIRSTNAME', '`delivery_address_join`.FIRSTNAME')->addAsColumn('delivery_address_LASTNAME', '`delivery_address_join`.LASTNAME')->addAsColumn('delivery_address_ADDRESS1', '`delivery_address_join`.ADDRESS1')->addAsColumn('delivery_address_ADDRESS2', '`delivery_address_join`.ADDRESS2')->addAsColumn('delivery_address_ADDRESS3', '`delivery_address_join`.ADDRESS3')->addAsColumn('delivery_address_ZIPCODE', '`delivery_address_join`.ZIPCODE')->addAsColumn('delivery_address_CITY', '`delivery_address_join`.CITY')->addAsColumn('delivery_address_PHONE', '`delivery_address_join`.PHONE')->endUse()->endUse()->useOrderAddressRelatedByInvoiceOrderAddressIdQuery('invoice_address_join')->useCustomerTitleQuery('invoice_address_customer_title_join')->useCustomerTitleI18nQuery('invoice_address_customer_title_i18n_join')->addAsColumn('invoice_address_TITLE', '`invoice_address_customer_title_i18n_join`.SHORT')->endUse()->endUse()->useCountryQuery('invoice_address_country_join')->useCountryI18nQuery('invoice_address_country_i18n_join')->addAsColumn('invoice_address_country_TITLE', '`invoice_address_country_i18n_join`.TITLE')->endUse()->endUse()->addAsColumn('invoice_address_COMPANY', '`invoice_address_join`.COMPANY')->addAsColumn('invoice_address_FIRSTNAME', '`invoice_address_join`.FIRSTNAME')->addAsColumn('invoice_address_LASTNAME', '`invoice_address_join`.LASTNAME')->addAsColumn('invoice_address_ADDRESS1', '`invoice_address_join`.ADDRESS1')->addAsColumn('invoice_address_ADDRESS2', '`invoice_address_join`.ADDRESS2')->addAsColumn('invoice_address_ADDRESS3', '`invoice_address_join`.ADDRESS3')->addAsColumn('invoice_address_ZIPCODE', '`invoice_address_join`.ZIPCODE')->addAsColumn('invoice_address_CITY', '`invoice_address_join`.CITY')->addAsColumn('invoice_address_PHONE', '`invoice_address_join`.PHONE')->endUse()->useOrderStatusQuery()->useOrderStatusI18nQuery()->addAsColumn('order_status_TITLE', OrderStatusI18nTableMap::TITLE)->endUse()->endUse()->select([OrderTableMap::REF, 'customer_REF', 'product_TITLE', 'product_PRICE', 'product_TAX', 'tax_TITLE', 'product_QUANTITY', 'product_WAS_IN_PROMO', OrderTableMap::DISCOUNT, 'coupon_COUPONS', OrderTableMap::POSTAGE, 'payment_module_TITLE', OrderTableMap::INVOICE_REF, OrderTableMap::DELIVERY_REF, 'delivery_module_TITLE', 'delivery_address_TITLE', 'delivery_address_COMPANY', 'delivery_address_FIRSTNAME', 'delivery_address_LASTNAME', 'delivery_address_ADDRESS1', 'delivery_address_ADDRESS2', 'delivery_address_ADDRESS3', 'delivery_address_ZIPCODE', 'delivery_address_CITY', 'delivery_address_country_TITLE', 'delivery_address_PHONE', 'invoice_address_TITLE', 'invoice_address_COMPANY', 'invoice_address_FIRSTNAME', 'invoice_address_LASTNAME', 'invoice_address_ADDRESS1', 'invoice_address_ADDRESS2', 'invoice_address_ADDRESS3', 'invoice_address_ZIPCODE', 'invoice_address_CITY', 'invoice_address_country_TITLE', 'invoice_address_PHONE', 'order_status_TITLE', 'currency_CODE', OrderTableMap::CREATED_AT])->orderByCreatedAt(Criteria::DESC); I18n::addI18nCondition($query, CustomerTitleI18nTableMap::TABLE_NAME, '`delivery_address_customer_title_join`.ID', CustomerTitleI18nTableMap::ID, '`delivery_address_customer_title_i18n_join`.LOCALE', $locale); I18n::addI18nCondition($query, CustomerTitleI18nTableMap::TABLE_NAME, '`invoice_address_customer_title_join`.ID', CustomerTitleI18nTableMap::ID, '`invoice_address_customer_title_i18n_join`.LOCALE', $locale); I18n::addI18nCondition($query, CountryI18nTableMap::TABLE_NAME, '`delivery_address_country_join`.ID', CountryI18nTableMap::ID, '`delivery_address_country_i18n_join`.LOCALE', $locale); I18n::addI18nCondition($query, CountryI18nTableMap::TABLE_NAME, '`invoice_address_country_join`.ID', CountryI18nTableMap::ID, '`invoice_address_country_i18n_join`.LOCALE', $locale); I18n::addI18nCondition($query, OrderStatusI18nTableMap::TABLE_NAME, OrderStatusI18nTableMap::ID, OrderStatusTableMap::ID, OrderStatusI18nTableMap::LOCALE, $locale); $data = $query->filterById($order[OrderTableMap::ID])->findOne(); $order = (new Order())->setId($order[OrderTableMap::ID]); $order->setNew(false); $tax = 0; $data['order_TOTAL_TTC'] = $order->getTotalAmount($tax, false, false); $data['order_TOTAL_WITH_DISCOUNT'] = $order->getTotalAmount($tax, false, true); $data['order_TOTAL_WITH_DISCOUNT_AND_POSTAGE'] = $order->getTotalAmount($tax, true, true); return $data; }
protected function getQuery(Lang $lang) { $locale = $lang->getLocale(); $query = OrderQuery::create()->useCurrencyQuery()->addAsColumn("currency_CODE", CurrencyTableMap::CODE)->endUse()->useCustomerQuery()->addAsColumn("customer_REF", CustomerTableMap::REF)->endUse()->useOrderProductQuery()->useOrderProductTaxQuery(null, Criteria::LEFT_JOIN)->addAsColumn("product_TAX", "IF(" . OrderProductTableMap::WAS_IN_PROMO . "," . "SUM(" . OrderProductTaxTableMap::PROMO_AMOUNT . ")," . "SUM(" . OrderProductTaxTableMap::AMOUNT . ")" . ")")->addAsColumn("tax_TITLE", OrderProductTableMap::TAX_RULE_TITLE)->endUse()->addAsColumn("product_TITLE", OrderProductTableMap::TITLE)->addAsColumn("product_PRICE", "IF(" . OrderProductTableMap::WAS_IN_PROMO . "," . OrderProductTableMap::PROMO_PRICE . "," . OrderProductTableMap::PRICE . ")")->addAsColumn("product_QUANTITY", OrderProductTableMap::QUANTITY)->addAsColumn("product_WAS_IN_PROMO", OrderProductTableMap::WAS_IN_PROMO)->groupById()->endUse()->orderById()->groupById()->useOrderCouponQuery(null, Criteria::LEFT_JOIN)->addAsColumn("coupon_COUPONS", "GROUP_CONCAT(" . OrderCouponTableMap::TITLE . ")")->groupBy(OrderCouponTableMap::ORDER_ID)->endUse()->useModuleRelatedByPaymentModuleIdQuery("payment_module")->addAsColumn("payment_module_TITLE", "`payment_module`.CODE")->endUse()->useModuleRelatedByDeliveryModuleIdQuery("delivery_module")->addAsColumn("delivery_module_TITLE", "`delivery_module`.CODE")->endUse()->useOrderAddressRelatedByDeliveryOrderAddressIdQuery("delivery_address_join")->useCustomerTitleQuery("delivery_address_customer_title_join")->useCustomerTitleI18nQuery("delivery_address_customer_title_i18n_join")->addAsColumn("delivery_address_TITLE", "`delivery_address_customer_title_i18n_join`.SHORT")->endUse()->endUse()->useCountryQuery("delivery_address_country_join")->useCountryI18nQuery("delivery_address_country_i18n_join")->addAsColumn("delivery_address_country_TITLE", "`delivery_address_country_i18n_join`.TITLE")->endUse()->addAsColumn("delivery_address_COMPANY", "`delivery_address_join`.COMPANY")->addAsColumn("delivery_address_FIRSTNAME", "`delivery_address_join`.FIRSTNAME")->addAsColumn("delivery_address_LASTNAME", "`delivery_address_join`.LASTNAME")->addAsColumn("delivery_address_ADDRESS1", "`delivery_address_join`.ADDRESS1")->addAsColumn("delivery_address_ADDRESS2", "`delivery_address_join`.ADDRESS2")->addAsColumn("delivery_address_ADDRESS3", "`delivery_address_join`.ADDRESS3")->addAsColumn("delivery_address_ZIPCODE", "`delivery_address_join`.ZIPCODE")->addAsColumn("delivery_address_CITY", "`delivery_address_join`.CITY")->addAsColumn("delivery_address_PHONE", "`delivery_address_join`.PHONE")->endUse()->endUse()->useOrderAddressRelatedByInvoiceOrderAddressIdQuery("invoice_address_join")->useCustomerTitleQuery("invoice_address_customer_title_join")->useCustomerTitleI18nQuery("invoice_address_customer_title_i18n_join")->addAsColumn("invoice_address_TITLE", "`invoice_address_customer_title_i18n_join`.SHORT")->endUse()->endUse()->useCountryQuery("invoice_address_country_join")->useCountryI18nQuery("invoice_address_country_i18n_join")->addAsColumn("invoice_address_country_TITLE", "`invoice_address_country_i18n_join`.TITLE")->endUse()->endUse()->addAsColumn("invoice_address_COMPANY", "`invoice_address_join`.COMPANY")->addAsColumn("invoice_address_FIRSTNAME", "`invoice_address_join`.FIRSTNAME")->addAsColumn("invoice_address_LASTNAME", "`invoice_address_join`.LASTNAME")->addAsColumn("invoice_address_ADDRESS1", "`invoice_address_join`.ADDRESS1")->addAsColumn("invoice_address_ADDRESS2", "`invoice_address_join`.ADDRESS2")->addAsColumn("invoice_address_ADDRESS3", "`invoice_address_join`.ADDRESS3")->addAsColumn("invoice_address_ZIPCODE", "`invoice_address_join`.ZIPCODE")->addAsColumn("invoice_address_CITY", "`invoice_address_join`.CITY")->addAsColumn("invoice_address_PHONE", "`invoice_address_join`.PHONE")->endUse()->useOrderStatusQuery()->useOrderStatusI18nQuery()->addAsColumn("order_status_TITLE", OrderStatusI18nTableMap::TITLE)->endUse()->endUse()->select([OrderTableMap::REF, "customer_REF", "product_TITLE", "product_PRICE", "product_TAX", "tax_TITLE", "product_QUANTITY", "product_WAS_IN_PROMO", OrderTableMap::DISCOUNT, "coupon_COUPONS", OrderTableMap::POSTAGE, "payment_module_TITLE", OrderTableMap::INVOICE_REF, OrderTableMap::DELIVERY_REF, "delivery_module_TITLE", "delivery_address_TITLE", "delivery_address_COMPANY", "delivery_address_FIRSTNAME", "delivery_address_LASTNAME", "delivery_address_ADDRESS1", "delivery_address_ADDRESS2", "delivery_address_ADDRESS3", "delivery_address_ZIPCODE", "delivery_address_CITY", "delivery_address_country_TITLE", "delivery_address_PHONE", "invoice_address_TITLE", "invoice_address_COMPANY", "invoice_address_FIRSTNAME", "invoice_address_LASTNAME", "invoice_address_ADDRESS1", "invoice_address_ADDRESS2", "invoice_address_ADDRESS3", "invoice_address_ZIPCODE", "invoice_address_CITY", "invoice_address_country_TITLE", "invoice_address_PHONE", "order_status_TITLE", "currency_CODE", OrderTableMap::CREATED_AT])->orderByCreatedAt(Criteria::DESC); I18n::addI18nCondition($query, CustomerTitleI18nTableMap::TABLE_NAME, "`delivery_address_customer_title_join`.ID", CustomerTitleI18nTableMap::ID, "`delivery_address_customer_title_i18n_join`.LOCALE", $locale); I18n::addI18nCondition($query, CustomerTitleI18nTableMap::TABLE_NAME, "`invoice_address_customer_title_join`.ID", CustomerTitleI18nTableMap::ID, "`invoice_address_customer_title_i18n_join`.LOCALE", $locale); I18n::addI18nCondition($query, CountryI18nTableMap::TABLE_NAME, "`delivery_address_country_join`.ID", CountryI18nTableMap::ID, "`delivery_address_country_i18n_join`.LOCALE", $locale); I18n::addI18nCondition($query, CountryI18nTableMap::TABLE_NAME, "`invoice_address_country_join`.ID", CountryI18nTableMap::ID, "`invoice_address_country_i18n_join`.LOCALE", $locale); I18n::addI18nCondition($query, OrderStatusI18nTableMap::TABLE_NAME, OrderStatusI18nTableMap::ID, OrderStatusTableMap::ID, OrderStatusI18nTableMap::LOCALE, $locale); return $query; }
public function buildDataSet(Lang $lang) { /** @var \Thelia\Model\AttributeCombinationQuery $query */ $query = parent::buildDataSet($lang); $pseJoin = new Join(AttributeCombinationTableMap::PRODUCT_SALE_ELEMENTS_ID, ProductSaleElementsTableMap::ID); $pseJoin->setRightTableAlias("pse_tax_join"); $productJoin = new Join(ProductSaleElementsTableMap::ID, ProductTableMap::ID); $productJoin->setRightTableAlias("product_tax_join"); $taxJoin = new Join("`product_tax_join`.TAX_RULE_ID", TaxRuleTableMap::ID, Criteria::LEFT_JOIN); $taxI18nJoin = new Join(TaxRuleTableMap::ID, TaxRuleI18nTableMap::ID, Criteria::LEFT_JOIN); $query->addJoinObject($pseJoin, "pse_tax_join")->addJoinObject($productJoin, "product_tax_join")->addJoinObject($productJoin)->addJoinObject($taxJoin)->addJoinObject($taxI18nJoin)->addAsColumn("product_TAX_TITLE", TaxRuleI18nTableMap::TITLE)->addAsColumn("tax_ID", TaxRuleTableMap::ID)->select($query->getSelect() + ["product_TAX_TITLE", "tax_ID"]); I18n::addI18nCondition($query, TaxRuleI18nTableMap::TABLE_NAME, TaxRuleTableMap::ID, TaxRuleI18nTableMap::ID, TaxRuleI18nTableMap::LOCALE, $lang->getLocale()); $dataSet = $query->keepQuery(true)->find()->toArray(); $productSaleElements = ProductSaleElementsQuery::create()->find()->toKeyIndex("Id"); $currencies = CurrencyQuery::create()->find()->toKeyIndex("Code"); foreach ($dataSet as &$line) { /** @var \Thelia\Model\ProductSaleElements $pse */ $pse = $productSaleElements[$line["product_sale_elements_ID"]]; $pricesTools = $pse->getPricesByCurrency($currencies[$line["currency_CODE"]]); $line["price_PRICE"] = $pricesTools->getPrice(); $line["price_PROMO_PRICE"] = $pricesTools->getPromoPrice(); } return $dataSet; }
/** * @param Lang $lang * @return array|\Propel\Runtime\ActiveQuery\ModelCriteria * * The tax engine of Thelia is in PHP, so we can't compute orders for each customers * directly in SQL, we need two SQL queries, and some computing to get the last order amount and total amount. */ public function buildDataSet(Lang $lang) { $locale = $lang->getLocale(); /** * This first query get each customer info and addresses. */ $newsletterJoin = new Join(CustomerTableMap::EMAIL, NewsletterTableMap::EMAIL, Criteria::LEFT_JOIN); $query = CustomerQuery::create()->useCustomerTitleQuery("customer_title_")->useCustomerTitleI18nQuery("customer_title_i18n_")->addAsColumn("title_TITLE", "customer_title_i18n_.SHORT")->endUse()->endUse()->useAddressQuery()->useCountryQuery()->useCountryI18nQuery()->addAsColumn("address_COUNTRY", CountryI18nTableMap::TITLE)->endUse()->endUse()->useCustomerTitleQuery("address_title")->useCustomerTitleI18nQuery("address_title_i18n")->addAsColumn("address_TITLE", "address_title_i18n.SHORT")->endUse()->endUse()->addAsColumn("address_LABEL", AddressTableMap::LABEL)->addAsColumn("address_FIRST_NAME", AddressTableMap::FIRSTNAME)->addAsColumn("address_LAST_NAME", AddressTableMap::LASTNAME)->addAsColumn("address_COMPANY", AddressTableMap::COMPANY)->addAsColumn("address_ADDRESS1", AddressTableMap::ADDRESS1)->addAsColumn("address_ADDRESS2", AddressTableMap::ADDRESS2)->addAsColumn("address_ADDRESS3", AddressTableMap::ADDRESS3)->addAsColumn("address_ZIPCODE", AddressTableMap::ZIPCODE)->addAsColumn("address_CITY", AddressTableMap::CITY)->addAsColumn("address_PHONE", AddressTableMap::PHONE)->addAsColumn("address_CELLPHONE", AddressTableMap::CELLPHONE)->addAsColumn("address_IS_DEFAULT", AddressTableMap::IS_DEFAULT)->endUse()->addJoinObject($newsletterJoin)->addAsColumn("newsletter_IS_REGISTRED", "IF(NOT ISNULL(" . NewsletterTableMap::EMAIL . "),1,0)")->select([CustomerTableMap::ID, CustomerTableMap::REF, CustomerTableMap::LASTNAME, CustomerTableMap::FIRSTNAME, CustomerTableMap::EMAIL, CustomerTableMap::DISCOUNT, CustomerTableMap::CREATED_AT, "title_TITLE", "address_TITLE", "address_LABEL", "address_COMPANY", "address_FIRST_NAME", "address_LAST_NAME", "address_ADDRESS1", "address_ADDRESS2", "address_ADDRESS3", "address_ZIPCODE", "address_CITY", "address_COUNTRY", "address_PHONE", "address_CELLPHONE", "address_IS_DEFAULT", "newsletter_IS_REGISTRED"])->orderById(); I18n::addI18nCondition($query, CountryI18nTableMap::TABLE_NAME, CountryTableMap::ID, CountryI18nTableMap::ID, CountryI18nTableMap::LOCALE, $locale); I18n::addI18nCondition($query, CustomerTitleI18nTableMap::TABLE_NAME, "`customer_title_`.ID", "`customer_title_i18n_`.ID", "`customer_title_i18n_`.LOCALE", $locale); I18n::addI18nCondition($query, CustomerTitleI18nTableMap::TABLE_NAME, "`address_title`.ID", "`address_title_i18n`.ID", "`address_title_i18n`.LOCALE", $locale); /** @var CustomerQuery $query */ $results = $query->find()->toArray(); /** * Then get the orders */ $orders = OrderQuery::create()->useCustomerQuery()->orderById()->endUse()->find(); /** * And add them info the array */ $orders->rewind(); $arrayLength = count($results); $previousCustomerId = null; for ($i = 0; $i < $arrayLength; ++$i) { $currentCustomer =& $results[$i]; $currentCustomerId = $currentCustomer[CustomerTableMap::ID]; unset($currentCustomer[CustomerTableMap::ID]); if ($currentCustomerId === $previousCustomerId) { $currentCustomer["title_TITLE"] = ""; $currentCustomer[CustomerTableMap::LASTNAME] = ""; $currentCustomer[CustomerTableMap::FIRSTNAME] = ""; $currentCustomer[CustomerTableMap::EMAIL] = ""; $currentCustomer["address_COMPANY"] = ""; $currentCustomer["newsletter_IS_REGISTRED"] = ""; $currentCustomer[CustomerTableMap::CREATED_AT] = ""; $currentCustomer[CustomerTableMap::DISCOUNT] = ""; $currentCustomer += ["order_TOTAL" => "", "last_order_AMOUNT" => "", "last_order_DATE" => ""]; } else { /** * Reformat created_at date */ $date = $currentCustomer[CustomerTableMap::CREATED_AT]; $dateTime = new \DateTime($date); $currentCustomer[CustomerTableMap::CREATED_AT] = $dateTime->format($lang->getDatetimeFormat()); /** * Then compute everything about the orders */ $total = 0; $lastOrderAmount = 0; $lastOrderDate = null; $lastOrder = null; $lastOrderCurrencyCode = null; $lastOrderId = 0; $defaultCurrency = Currency::getDefaultCurrency(); $defaultCurrencyCode = $defaultCurrency->getCode(); if (empty($defaultCurrencyCode)) { $defaultCurrencyCode = $defaultCurrency->getCode(); } $formattedDate = null; /** @var \Thelia\Model\Order $currentOrder */ while (false !== ($currentOrder = $orders->current())) { if ($currentCustomerId != $currentOrder->getCustomerId()) { break; } $amount = $currentOrder->getTotalAmount($tax); if (0 < ($rate = $currentOrder->getCurrencyRate())) { $amount = round($amount / $rate, 2); } $total += $amount; /** @var \DateTime $date */ $date = $currentOrder->getCreatedAt(); if (null === $lastOrderDate || $date >= $lastOrderDate && $lastOrderId < $currentOrder->getId()) { $lastOrder = $currentOrder; $lastOrderDate = $date; $lastOrderId = $currentOrder->getId(); } $orders->next(); } if ($lastOrderDate !== null) { $formattedDate = $lastOrderDate->format($lang->getDatetimeFormat()); $orderCurrency = $lastOrder->getCurrency(); $lastOrderCurrencyCode = $orderCurrency->getCode(); if (empty($lastOrderCurrencyCode)) { $lastOrderCurrencyCode = $orderCurrency->getCode(); } $lastOrderAmount = $lastOrder->getTotalAmount($tax_); } $currentCustomer += ["order_TOTAL" => $total . " " . $defaultCurrencyCode, "last_order_AMOUNT" => $lastOrderAmount === 0 ? "" : $lastOrderAmount . " " . $lastOrderCurrencyCode, "last_order_DATE" => $formattedDate]; } $previousCustomerId = $currentCustomerId; } return $results; }