Exemplo n.º 1
0
 private static function can_call_next_action()
 {
     if (self::$call_next_action == false) {
         self::$call_next_action = true;
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 function jigoshop_complete_processing_orders()
 {
     if (self::get_options()->get('jigoshop_complete_processing_orders') == 'yes') {
         add_filter('posts_where', array($this, 'orders_filter_when'));
         $orders = get_posts(array('post_status' => 'publish', 'post_type' => 'shop_order', 'shop_order_status' => 'processing', 'suppress_filters' => false, 'fields' => 'ids'));
         remove_filter('posts_where', array($this, 'orders_filter_when'));
         jigoshop_emails::suppress_next_action();
         foreach ($orders as $index => $order_id) {
             $order = new jigoshop_order($order_id);
             $order->update_status('completed', __('Completed due to order being in processing state for a month or longer.', 'jigoshop'));
         }
     }
 }
Exemplo n.º 3
0
function jigoshop_install_emails()
{
    $default_emails = array('new_order_admin_notification', 'customer_order_status_pending_to_processing', 'customer_order_status_pending_to_on-hold', 'customer_order_status_pending_to_waiting-for-payment', 'customer_order_status_on-hold_to_processing', 'customer_order_status_waiting-for-payment_to_processing', 'customer_order_status_completed', 'customer_order_status_refunded', 'send_customer_invoice', 'low_stock_notification', 'no_stock_notification', 'product_on_backorder_notification');
    $invoice = '
		[is_cheque]
			<p>' . _x('We are waiting for your cheque before we can start processing this order.', 'emails', 'jigoshop') . '</p>
			<p>[cheque_info]</p>
			<p>Total value: [total]</p>
		[else]
		[is_bank_transfer]
			<p>' . _x('We are waiting for your payment before we can start processing this order.', 'emails', 'jigoshop') . '</p>
			<h4>' . _x('Bank details', 'emails', 'jigoshop') . '</h4>
			[bank_info]
			<p>Total value: [total]</p>
		[else]
		[is_local_pickup]
		<h4>' . _x('Your order is being prepared', 'emails', 'jigoshop') . '</h4>
		<p>' . _x('We are preparing your order, you will receive another email when we will be ready and awaiting for you to pick it up.', 'emails', 'jigoshop') . '</p>
		[else]
		[is_cash_on_delivery]
		<h4>' . _x('Order will be dispatched shortly', 'emails', 'jigoshop') . '</h4>
		<p>' . _x('Your order is being processed and will be dispatched to you as soon as possible. Please prepare exact change to pay when package arrives.', 'emails', 'jigoshop') . '</p>
		[/is_cash_on_delivery]
		[/is_local_pickup]
		[/is_bank_transfer]
		[/is_cheque]
		<h4>' . _x('Order [order_number] on [order_date]', 'emails', 'jigoshop') . '</h4>
		[order_items_table]
		<h4>' . _x('Customer details', 'emails', 'jigoshop') . '</h4>
		<p>' . _x('Email:', 'emails', 'jigoshop') . ' <a href="mailto:[billing_email]">[billing_email]</a></p>
		<p>' . _x('Phone:', 'emails', 'jigoshop') . ' [billing_phone]</p>
		<table class="customer">
			<thead>
				<tr>
					<td><strong>' . _x('Billing address', 'emails', 'jigoshop') . '</strong></td>
					<td><strong>' . _x('Shipping address', 'emails', 'jigoshop') . '</strong></td>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>
						[billing_first_name] [billing_last_name]<br />
						[billing_address_1][billing_address_2], [value][/billing_address_2]<br />
						[billing_city], [billing_postcode]<br />
						[billing_state]<br />
						[billing_country]
					</td>
					<td>
						[shipping_first_name] [shipping_last_name]<br />
						[shipping_address_1][shipping_address_2], [value][/shipping_address_2]<br />
						[shipping_city], [shipping_postcode]<br />
						[shipping_state]<br />
						[shipping_country]
					</td>
				</tr>
			</tbody>
		</table>
		[customer_note]
		<h4>' . _x('Customer note', 'emails', 'jigoshop') . '</h4>
		<p>[value]</p>
		[/customer_note]
	';
    $title = '';
    $message = '';
    $post_title = '';
    foreach ($default_emails as $email) {
        switch ($email) {
            case 'new_order_admin_notification':
                $post_title = __('New order admin notification', 'jigoshop');
                $title = __('[[shop_name]] New Customer Order', 'jigoshop');
                $message = __('<p>You have received an order from [billing_first_name] [billing_last_name].</p><p>Current order status: <strong>[order_status]</strong></p>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_pending_to_on-hold':
                $post_title = __('Customer order status pending to on-hold', 'jigoshop');
                $title = __('[[shop_name]] Order Received', 'jigoshop');
                $message = __('<p>Thank you, we have received your order.</p>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_pending_to_waiting-for-payment':
                $post_title = __('Customer order status pending to waiting for payment', 'jigoshop');
                $title = __('[[shop_name]] Order Received - waiting for payment', 'jigoshop');
                $message = __('<p>Thank you, we have received your order.</p>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_pending_to_processing':
                $post_title = __('Customer order status pending to processing', 'jigoshop');
                $title = __('[[shop_name]] Order Received', 'jigoshop');
                $message = __('<p>Thank you, we are now processing your order.<br/>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_waiting-for-payment_to_processing':
                $post_title = __('Customer order status waiting for payment to processing', 'jigoshop');
                $title = __('[[shop_name]] Order Received', 'jigoshop');
                $message = __('<p>Thank you, we are now processing your order.<br/>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_on-hold_to_processing':
                $post_title = __('Customer order status on-hold to processing', 'jigoshop');
                $title = __('[[shop_name]] Order Received', 'jigoshop');
                $message = __('<p>Thank you, we are now processing your order.<br/>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_completed':
                $post_title = __('Customer order status completed', 'jigoshop');
                $title = __('[[shop_name]] Order Complete', 'jigoshop');
                $message = __('<p>Your order is complete.<br/>', 'jigoshop') . $invoice;
                break;
            case 'customer_order_status_refunded':
                $post_title = __('Customer order status refunded', 'jigoshop');
                $title = __('[[shop_name]] Order Refunded', 'jigoshop');
                $message = __('<p>Your order has been refunded.</p>', 'jigoshop') . $invoice;
                break;
            case 'send_customer_invoice':
                $post_title = __('Send customer invoice', 'jigoshop');
                $title = __('Invoice for Order: [order_number]', 'jigoshop');
                $message = $invoice;
                break;
            case 'low_stock_notification':
                $post_title = __('Low stock notification', 'jigoshop');
                $title = __('[[shop_name]] Product low in stock', 'jigoshop');
                $message = __('<p>#[product_id] [product_name] ([sku]) is low in stock.</p>', 'jigoshop');
                break;
            case 'no_stock_notification':
                $post_title = __('No stock notification', 'jigoshop');
                $title = __('[[shop_name]] Product out of stock', 'jigoshop');
                $message = __('<p>#[product_id] [product_name] ([sku]) is out of stock.</p>', 'jigoshop');
                break;
            case 'product_on_backorder_notification':
                $post_title = __('Product on backorder notification', 'jigoshop');
                $title = __('[[shop_name]] Product Backorder on Order: [order_number].', 'jigoshop');
                $message = __('<p>#[product_id] [product_name] ([sku]) was found to be on backorder.</p>', 'jigoshop') . $invoice;
                break;
        }
        $post_data = array('post_content' => $message, 'post_title' => $post_title, 'post_status' => 'publish', 'post_type' => 'shop_email', 'post_author' => 1, 'ping_status' => 'closed', 'comment_status' => 'closed');
        $post_id = wp_insert_post($post_data);
        update_post_meta($post_id, 'jigoshop_email_subject', $title);
        if ($email == 'new_order_admin_notification') {
            jigoshop_emails::set_actions($post_id, array('admin_order_status_pending_to_processing', 'admin_order_status_pending_to_completed', 'admin_order_status_pending_to_on-hold', 'admin_order_status_pending_to_waiting-for-payment'));
            update_post_meta($post_id, 'jigoshop_email_actions', array('admin_order_status_pending_to_processing', 'admin_order_status_pending_to_completed', 'admin_order_status_pending_to_on-hold', 'admin_order_status_pending_to_waiting-for-payment'));
        } else {
            jigoshop_emails::set_actions($post_id, array($email));
            update_post_meta($post_id, 'jigoshop_email_actions', array($email));
        }
    }
    \Jigoshop_Base::get_options()->set('jigoshop_enable_html_emails', 'yes');
}
Exemplo n.º 4
0
function update_variable_list($post = '')
{
    ?>
<div id="avalible_arguments">
		<table width="100%">
			<?php 
    $i = 0;
    $selected = isset($_POST['jigoshop_email_actions']) ? $_POST['jigoshop_email_actions'] : (array) get_post_meta($post->ID, 'jigoshop_email_actions', true);
    $registered_mails = jigoshop_emails::get_mail_list();
    if (!empty($selected[0]) && !empty($registered_mails[$selected[0]])) {
        $keys = array_keys($registered_mails[$selected[0]]['accepted_args']);
        if (count($selected) > 1) {
            foreach ($selected as $hook) {
                $keys = array_intersect(array_keys($registered_mails[$hook]['accepted_args']), $keys);
            }
        }
        asort($keys);
        if (empty($keys)) {
            _e('Selected actions have not common variables', 'jigoshop');
        }
        foreach ($keys as $key) {
            ?>
					<?php 
            if ($i % 3 == 0) {
                ?>
 <tr> <?php 
            }
            ?>
						<td width="33.33%"><strong>[<?php 
            echo $key;
            ?>
] </strong> - <?php 
            echo $registered_mails[$selected[0]]['accepted_args'][$key];
            ?>
 <br/>
					<?php 
            if ($i % 3 == 2) {
                ?>
 </tr> <?php 
            }
            ?>
					<?php 
            $i++;
            ?>
				<?php 
        }
    } else {
        _e('Select email action to see avalible variables', 'jigoshop');
    }
    ?>
		</table>
	</div><?php 
}