function fflcommerce_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_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', 'fflcommerce') . '</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', 'fflcommerce') . '</p> <h4>' . _x('Bank details', 'emails', 'fflcommerce') . '</h4> [bank_info] <p>Total value: [total]</p> [else] [is_local_pickup] <h4>' . _x('Your order is being prepared', 'emails', 'fflcommerce') . '</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', 'fflcommerce') . '</p> [else] [is_cash_on_delivery] <h4>' . _x('Order will be dispatched shortly', 'emails', 'fflcommerce') . '</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', 'fflcommerce') . '</p> [/is_cash_on_delivery] [/is_local_pickup] [/is_bank_transfer] [/is_cheque] <h4>' . _x('Order [order_number] on [order_date]', 'emails', 'fflcommerce') . '</h4> [order_items_table] <h4>' . _x('Customer details', 'emails', 'fflcommerce') . '</h4> <p>' . _x('Email:', 'emails', 'fflcommerce') . ' <a href="mailto:[billing_email]">[billing_email]</a></p> <p>' . _x('Phone:', 'emails', 'fflcommerce') . ' [billing_phone]</p> <table class="customer"> <thead> <tr> <td><strong>' . _x('Billing address', 'emails', 'fflcommerce') . '</strong></td> <td><strong>' . _x('Shipping address', 'emails', 'fflcommerce') . '</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', 'fflcommerce') . '</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', 'fflcommerce'); $title = __('[[shop_name]] New Customer Order', 'fflcommerce'); $message = __('<p>You have received an order from [billing_first_name] [billing_last_name].</p><p>Current order status: <strong>[order_status]</strong></p>', 'fflcommerce') . $invoice; break; case 'customer_order_status_pending_to_on-hold': $post_title = __('Customer order status pending to on-hold', 'fflcommerce'); $title = __('[[shop_name]] Order Received', 'fflcommerce'); $message = __('<p>Thank you, we have received your order.</p>', 'fflcommerce') . $invoice; break; case 'customer_order_status_pending_to_waiting-for-payment': $post_title = __('Customer order status pending to waiting for payment', 'fflcommerce'); $title = __('[[shop_name]] Order Received - waiting for payment', 'fflcommerce'); $message = __('<p>Thank you, we have received your order.</p>', 'fflcommerce') . $invoice; break; case 'customer_order_status_pending_to_processing': $post_title = __('Customer order status pending to processing', 'fflcommerce'); $title = __('[[shop_name]] Order Received', 'fflcommerce'); $message = __('<p>Thank you, we are now processing your order.<br/>', 'fflcommerce') . $invoice; break; case 'customer_order_status_on-hold_to_processing': $post_title = __('Customer order status on-hold to processing', 'fflcommerce'); $title = __('[[shop_name]] Order Received', 'fflcommerce'); $message = __('<p>Thank you, we are now processing your order.<br/>', 'fflcommerce') . $invoice; break; case 'customer_order_status_completed': $post_title = __('Customer order status completed', 'fflcommerce'); $title = __('[[shop_name]] Order Complete', 'fflcommerce'); $message = __('<p>Your order is complete.<br/>', 'fflcommerce') . $invoice; break; case 'customer_order_status_refunded': $post_title = __('Customer order status refunded', 'fflcommerce'); $title = __('[[shop_name]] Order Refunded', 'fflcommerce'); $message = __('<p>Your order has been refunded.</p>', 'fflcommerce') . $invoice; break; case 'send_customer_invoice': $post_title = __('Send customer invoice', 'fflcommerce'); $title = __('Invoice for Order: [order_number]', 'fflcommerce'); $message = $invoice; break; case 'low_stock_notification': $post_title = __('Low stock notification', 'fflcommerce'); $title = __('[[shop_name]] Product low in stock', 'fflcommerce'); $message = __('<p>#[product_id] [product_name] ([sku]) is low in stock.</p>', 'fflcommerce'); break; case 'no_stock_notification': $post_title = __('No stock notification', 'fflcommerce'); $title = __('[[shop_name]] Product out of stock', 'fflcommerce'); $message = __('<p>#[product_id] [product_name] ([sku]) is out of stock.</p>', 'fflcommerce'); break; case 'product_on_backorder_notification': $post_title = __('Product on backorder notification', 'fflcommerce'); $title = __('[[shop_name]] Product Backorder on Order: [order_number].', 'fflcommerce'); $message = __('<p>#[product_id] [product_name] ([sku]) was found to be on backorder.</p>', 'fflcommerce') . $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, 'fflcommerce_email_subject', $title); if ($email == 'new_order_admin_notification') { fflcommerce_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, 'fflcommerce_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 { fflcommerce_emails::set_actions($post_id, array($email)); update_post_meta($post_id, 'fflcommerce_email_actions', array($email)); } } \FFLCommerce_Base::get_options()->set('fflcommerce_enable_html_emails', 'yes'); }
function fflcommerce_process_shop_email_meta($post_id, $post) { update_post_meta($post_id, 'fflcommerce_email_subject', isset($_POST['fflcommerce_email_subject']) ? $_POST['fflcommerce_email_subject'] : ''); update_post_meta($post_id, 'fflcommerce_email_actions', isset($_POST['fflcommerce_email_actions']) ? $_POST['fflcommerce_email_actions'] : ''); fflcommerce_emails::set_actions($post_id, isset($_POST['fflcommerce_email_actions']) ? $_POST['fflcommerce_email_actions'] : ''); }