<?php
/** 
 * @package     VikRestaurants
 * @subpackage  core
 * @author      E4J s.r.l.
 * @copyright   Copyright (C) 2023 E4J s.r.l. All Rights Reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 * @link        https://vikwp.com
 */

namespace E4J\VikRestaurants\Upselling;

// No direct access
defined('ABSPATH') or die('No script kiddies please!');

/**
 * This interface can be used to collect the statistics needed to suggest
 * the best items for upselling.
 * 
 * @since 1.11
 */
interface StatisticsRepository
{
    /**
     * Self-train the system according to the currently saved records.
     * 
     * @return  void
     */
    public function train();

    /**
     * Counts how many orders we sold that contained both A and B items.
     * 
     * @param   int  $itemA  The ID of the first item (in cart).
     * @param   int  $itemB  The ID of the second item (upselling eligible).
     * 
     * @return  int  The A+B sales.
     */
    public function getItemsPair(int $itemA, int $itemB);

    /**
     * Counts how many orders we sold that contained the specified item.
     * 
     * @param   int  $item  The ID of the item.
     * 
     * @return  int  The item sales.
     */
    public function getItemTotal(int $item);

    /**
     * Returns the total number of orders.
     * 
     * @return  int  The orders count.
     */
    public function getTotalOrders();

    /**
     * Returns the date when the specified item was purchased for the very first time.
     * 
     * @param   int       $item  The ID of the item.
     * 
     * @return  int|null  The purchase unix timestamp. Null in case of missing details.
     */
    public function getItemCreation(int $item);
}
