backend_marketing_promo_orders

Allows modification of orders related to a promo and adding of custom content to that list’s section.

Shop-Script

Input (passed by reference)

$params['page'] int No. of current page in the order list.
$params['orders'] array List of orders.
$params['orders'][id] array Individual order’s properties.
$params['orders'][id]['items'] array List of ordered items.
$params['orders'][id]['params'] array Order parameters.
$params['orders'][id]['contact'] array Customer data.
… your plugin code …

Output

{$backend_marketing_promo_orders.%plugin_id%.top}

Extra content at the top of a promo’s orders listing area. E.g., an information block or a JavaScript code snippet.

Shop-Script

Plugin code example

PHP

public function backendMarketingPromoOrders(&$params)
{
    $new_customers_orders_count = 0;
    $counted_customers = [];

    foreach ($params['orders'] as &$order) {
        $customer_contact_id = $order['contact_id'];

        if (empty($counted_customers[$customer_contact_id])) {
            $counted_customers[$customer_contact_id] = true;

            $customer = new shopCustomer($customer_contact_id);
            $customer_orders_count = $customer->getCustomerData('number_of_orders');

            if ($customer_orders_count == 1) {
                $order['style'] .= 'text-transform: uppercase;';
                $new_customers_orders_count++;
            }
        }
    }

    return [
        'top'  => '<div class="block double-padded highlighted">'
            . sprintf_wp('Number of new customers’ orders: %d', $new_customers_orders_count)
            . '</div>',
    ];
}