Skip to main content

Checkout share

Reporting is an optional resource that can be implemented which will allow Simpler to ingest orders data from the shop and in doing so will allow stores several benefits when those data are combined with Simpler's analytics platform.

  • Benchmarking and Comparison: Insights can be gained into how their performance compares to industry averages and to evaluate the effectiveness of their current payment processing solutions. This information allows benchmarking the performance and identify areas for improvement.

  • Tailored Recommendations: With access to checkout share data, Simpler can offer personalized recommendations and insights to stores on how to optimize their payment processes.

  • Data-driven Decision Making: Sharing checkout share data with Simpler enables stores to make more informed, data-driven decisions regarding their payment infrastructure, pricing strategies, and customer experience enhancements. This can lead to more effective resource allocation and improved business outcomes.

Implementing reporting orders data

Reporting orders data is an offset based paginated resource, filtered by order added date, the full api spec of which can be found here.

The controller is matched at simpler/v1/reporting and uses the request offset data (page limit and current page) to retrieve the next set from the repository:

src/Controller/Simpler/ReportingController.php
class SimplerReportingController extends AbstractController {
public function postData(Request $request): Response {
$requestData = json_decode($request->getContent(), true);
$from = $requestData['from'];
$currentPage = $requestData['currentPage'];
$pageLimit = $requestData['pageLimit'];

$query = new DbQuery();
$query->select('o.id_order');
$query->select('o.payment_method');
$query->select('o.product_quantity as cart_size');
$query->select('o.total_paid');
$query->select('o.created_at');
$query->select('c.is_guest');
$query->select('a.iso_code as country_code');

$query->from('orders', 'o');

$query->Join('customer', 'c', 'c.id_customer = o.id_customer');
$query->Join('address', 'a', 'o.id_address_delivery = a.id_address');
$query->where('o.created_at > \'' . pSQL($from) . '\'');

$query->orderBy('o.created_at DESC');

$offset = 0;
if ($currentPage > 1) {
$offset = ($currentPage - 1) * $pageLimit;
}
$query->limit($pageLimit, $offset);

$result = Db::getInstance()->executeS($query);

$totalPages = self::getTotalPages($from, $pageLimit);

$orders = [];
foreach ($result as $order) {
$orders[] = [
'order_id' => (int) $order['id_order'],
'payment_method' => (string) $order['payment_method'],
'is_guest' => (int) $order['is_guest'],
'country_code' => (string) $order['country_code'],
'cart_size' => (int) $order['cart_size'],
'total_paid' => (float) $order['total_paid'],
'created_at' => (string) $order['created_at'],
];
}

return [
'request_id' => $requestData['request_id'],
'items' => $orders,
'total_pages' => $totalPages,
];
}

protected static function getTotalPages(string $from, int $pageLimit): int
{
$query = new DbQuery();
$query->select('COUNT(*)');
$query->from('orders');
$query->where('date_add > \'' . pSQL($from) . '\'');
$result = (int) Db::getInstance()->getValue($query);

return intval(ceil($result / $pageLimit));
}
}

Post implementation actions

Once you have implemented the resource let us know in order to enable the ingestion that will power the Checkout share section in the analytics dashboard.