/**
     * Trigger a notification
     * 
     * @access public
     * @param object $order
     * @param array $args
     * @param bool $send_to_admin
     * @return void
     */
    public function trigger($order, $args = array(), $send_to_admin = false)
    {
        if (!$order) {
            return;
        }

        $this->object = $order;

        if ($send_to_admin) {
            $this->recipient = get_option('admin_email');
        }
        else {
            $this->recipient = $this->object->billing_email;
        }

        // Replace macros
        $this->find[] = '{order_date}';
        $this->replace[] = date_i18n(wc_date_format(), strtotime($this->object->order_date));

        // Check if this email type is enabled, recipient is set and we are not on a development website
        if (!$this->is_enabled() || !$this->get_recipient() || !Subscriptio::is_main_site()) {
            return;
        }

        // Get subscription
        $subscription = Subscriptio_Order_Handler::get_subscriptions_from_order_id($order->id);
        $subscription = reset($subscription);

        if (!$subscription) {
            return;
        }

        $this->template_variables = array(
            'subscription'  => $subscription,
            'order'         => $this->object,
            'email_heading' => $this->get_heading(),
            'sent_to_admin' => false,
        );

        $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments());
    }
コード例 #2
0
ファイル: subscriptio.php プロジェクト: qhuit/dcosta
    /**
     * Display related subscriptions on single order view page
     * 
     * @access public
     * @param object $order
     * @return void
     */
    public function display_frontend_order_related_subscriptions($order)
    {
        $subscriptions = Subscriptio_Order_Handler::get_subscriptions_from_order_id($order->id);

        if (!empty($subscriptions) && apply_filters('subscriptio_display_order_related_subscriptions', true)) {
            Subscriptio::include_template('myaccount/subscription-list', array(
                'subscriptions' => $subscriptions,
                'title'         => __('Related Subscriptions', 'subscriptio'),
            ));
        }
    }