/** * trigger function. * * @access public * @return void */ function trigger($booking_id, $notification_subject, $notification_message, $attachments = array()) { global $woocommerce; if ($booking_id) { $this->object = get_wc_booking($booking_id); $this->recipient = $this->object->get_order()->billing_email; $this->find[] = '{product_title}'; $this->replace[] = $this->object->get_product()->get_title(); $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->get_order()->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order()->get_order_number(); $this->find[] = '{customer_name}'; $this->replace[] = $this->object->get_order()->billing_first_name . ' ' . $this->object->get_order()->billing_last_name; $this->find[] = '{customer_first_name}'; $this->replace[] = $this->object->get_order()->billing_first_name; $this->find[] = '{customer_last_name}'; $this->replace[] = $this->object->get_order()->billing_last_name; } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->heading = str_replace($this->find, $this->replace, $notification_subject); $this->subject = str_replace($this->find, $this->replace, $notification_subject); $this->notification_message = str_replace($this->find, $this->replace, $notification_message); $attachments = apply_filters('woocommerce_email_attachments', $attachments, $this->id, $this->object); $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $attachments); }
/** * trigger function. * * We need to override WC_Email_New_Order's trigger method because it expects to be run only once * per request. * * @access public * @return void */ function trigger($order_id) { if ($order_id) { $this->object = new WC_Order($order_id); $order_date_index = array_search('{order_date}', $this->find); if (false === $order_date_index) { $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); } else { $this->replace[$order_date_index] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); } $order_number_index = array_search('{order_number}', $this->find); if (false === $order_number_index) { $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } else { $this->replace[$order_number_index] = $this->object->get_order_number(); } $this->subscriptions = wcs_get_subscriptions_for_switch_order($this->object); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * trigger function. * * @access public * @return void * * @param unknown $order_id */ function trigger($order_id) { global $woocommerce; if ($order_id) { $this->object = new WC_Order($order_id); $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } if (!$this->is_enabled()) { return; } $vendors = $this->get_vendors($this->object); if (empty($vendors)) { return; } add_filter('woocommerce_order_get_items', array($this, 'check_items'), 10, 2); add_filter('woocommerce_get_order_item_totals', array($this, 'check_order_totals'), 10, 2); foreach ($vendors as $user_id => $user_email) { $this->current_vendor = $user_id; $this->send($user_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); } remove_filter('woocommerce_get_order_item_totals', array($this, 'check_order_totals'), 10, 2); remove_filter('woocommerce_order_get_items', array($this, 'check_items'), 10, 2); }
/** * trigger function. * * We need to override WC_Email_Customer_Invoice's trigger method because it expects to be run only once * per request (but multiple subscription renewal orders can be generated per request). * * @access public * @return void */ function trigger($order) { if (!is_object($order)) { $order = new WC_Order(absint($order)); } if ($order) { $this->object = $order; $this->recipient = $this->object->billing_email; $order_date_index = array_search('{order_date}', $this->find); if (false === $order_date_index) { $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); } else { $this->replace[$order_date_index] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); } $order_number_index = array_search('{order_number}', $this->find); if (false === $order_number_index) { $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } else { $this->replace[$order_number_index] = $this->object->get_order_number(); } } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Dispatch the email * * @since 1.0 */ public function trigger($args) { if (!empty($args)) { $defaults = array('order' => '', 'message' => ''); $args = wp_parse_args($args, $defaults); extract($args); if (!is_object($order)) { return; } $this->object = $order; $this->recipient = $this->object->billing_email; $this->message = $message; $this->availability_date = WC_Pre_Orders_Product::get_localized_availability_date(WC_Pre_Orders_Order::get_pre_order_product($this->object)); $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{release_date}'; $this->replace[] = $this->availability_date; $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Dispatch the email * * @since 1.0 */ public function trigger($order_id) { if ($order_id) { $this->object = new WC_Order($order_id); $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Determine if the email should actually be sent and setup email merge variables * * @since 0.1 * @param int $order_id */ public function trigger($order_id) { // setup order object $this->object = new WC_Order($order_id); $this->recipient = $this->object->billing_email; // replace variables in the subject/headings $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); if (!$this->is_enabled() || !$this->get_recipient()) { return; } // woohoo, send the email! $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
public function trigger($order) { if (is_numeric($order)) { $this->object = new WC_Order(absint($order)); } elseif ($order instanceof WC_Order) { $this->object = $order; } $this->recipient = $this->object->billing_email; $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); $this->find[] = '{date}'; $this->replace[] = date_i18n(woocommerce_date_format(), time()); if (!$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Trigger email. * * @param WC_Order $order Order data. * @param string $tracking_code Tracking code. * * @return void */ public function trigger($order, $tracking_code) { if (is_object($order)) { $this->object = $order; $this->recipient = $this->object->billing_email; $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); $this->find[] = '{date}'; $this->replace[] = date_i18n(woocommerce_date_format(), time()); $this->find[] = '{tracking_code}'; $this->replace[] = $this->get_tracking_code_url($tracking_code); } if (!$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Dispatch the email * * @since 1.0 */ public function trigger($order_id, $message) { if ($order_id) { $this->object = new WC_Order($order_id); $this->recipient = $this->object->billing_email; $this->message = $message; $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{release_date}'; $this->replace[] = WC_Pre_Orders_Product::get_localized_availability_date(WC_Pre_Orders_Order::get_pre_order_product($this->object)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * trigger function. * * @access public * @return void */ function trigger($booking_id) { global $woocommerce; if ($booking_id) { $this->object = get_wc_booking($booking_id); $this->recipient = $this->object->get_order()->billing_email; $this->find[] = '{product_title}'; $this->replace[] = $this->object->get_product()->get_title(); $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->get_order()->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order()->get_order_number(); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * trigger function. * * @access public * @return void */ function trigger($args) { if ($args) { $defaults = array('order_id' => '', 'customer_note' => ''); $args = wp_parse_args($args, $defaults); extract($args); $this->object = new WC_Order($order_id); $this->recipient = $this->object->billing_email; $this->customer_note = $customer_note; $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); } if (!$this->is_enabled() || !$this->get_recipient()) { return; } $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * Determine if the email should actually be sent and setup email merge variables * * @since 0.1 * @param int $order_id */ public function trigger($order_id) { // bail if no order ID is present if (!$order_id) { return; } // setup order object $this->object = new WC_Order($order_id); // bail if shipping method is not expedited if (!in_array($this->object->get_shipping_method(), array('Three Day Shipping', 'Next Day Shipping'))) { return; } // replace variables in the subject/headings $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); if (!$this->is_enabled() || !$this->get_recipient()) { return; } // woohoo, send the email! $this->send($this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments()); }
/** * If requesting a payment method change, replace the woocommerce_pay_shortcode() with a change payment form. * * @since 1.4 */ public static function maybe_replace_pay_shortcode() { global $woocommerce; if (!self::$is_request_to_change_payment) { return; } ob_clean(); do_action('before_woocommerce_pay'); echo '<div class="woocommerce">'; if (!empty(self::$woocommerce_errors)) { foreach (self::$woocommerce_errors as $error) { WC_Subscriptions::add_notice($error, 'error'); } } if (!empty(self::$woocommerce_messages)) { foreach (self::$woocommerce_messages as $message) { WC_Subscriptions::add_notice($message, 'success'); } } $subscription_key = $_GET['change_payment_method']; $subscription = WC_Subscriptions_Manager::get_subscription($subscription_key); if (wp_verify_nonce($_GET['_wpnonce'], __FILE__) === false) { WC_Subscriptions::add_notice(__('There was an error with your request. Please try again.', 'woocommerce-subscriptions'), 'error'); WC_Subscriptions::print_notices(); } elseif (!WC_Subscriptions_Manager::user_owns_subscription($subscription_key)) { WC_Subscriptions::add_notice(__('That doesn\'t appear to be one of your subscriptions.', 'woocommerce-subscriptions'), 'error'); WC_Subscriptions::print_notices(); } elseif (empty($subscription)) { WC_Subscriptions::add_notice(__('Invalid subscription.', 'woocommerce-subscriptions'), 'error'); WC_Subscriptions::print_notices(); } elseif (!WC_Subscriptions_Manager::can_subscription_be_changed_to('new-payment-method', $subscription_key, get_current_user_id())) { WC_Subscriptions::add_notice(__('The payment method can not be changed for that subscription.', 'woocommerce-subscriptions'), 'error'); WC_Subscriptions::print_notices(); } else { $order = new WC_Order($subscription['order_id']); $order_id = absint($_GET['order_id']); $order_key = isset($_GET['key']) ? $_GET['key'] : $_GET['order']; $product_id = $subscription['product_id']; $next_payment_timestamp = WC_Subscriptions_Order::get_next_payment_timestamp($order, $product_id); if (!empty($next_payment_timestamp)) { $next_payment_string = sprintf(__(' Next payment is due %s.', 'woocommerce-subscriptions'), date_i18n(woocommerce_date_format(), $next_payment_timestamp)); } else { $next_payment_string = ''; } WC_Subscriptions::add_notice(sprintf(__('Choose a new payment method.%s', 'woocommerce-subscriptions'), $next_payment_string), 'notice'); WC_Subscriptions::print_notices(); if ($order->order_key == $order_key) { // Set customer location to order location if ($order->billing_country) { $woocommerce->customer->set_country($order->billing_country); } if ($order->billing_state) { $woocommerce->customer->set_state($order->billing_state); } if ($order->billing_postcode) { $woocommerce->customer->set_postcode($order->billing_postcode); } // Show form WC_Subscriptions_Order::$recurring_only_price_strings = true; woocommerce_get_template('checkout/form-change-payment-method.php', array('order' => $order, 'subscription_key' => $subscription_key), '', plugin_dir_path(WC_Subscriptions::$plugin_file) . 'templates/'); WC_Subscriptions_Order::$recurring_only_price_strings = false; } else { WC_Subscriptions::add_notice(__('Invalid order.', 'woocommerce-subscriptions'), 'error'); WC_Subscriptions::print_notices(); } } }
* @version 2.0.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly echo $email_heading . "\n\n"; echo __("Hello, a note has just been added to your order:", 'woocommerce') . "\n\n"; echo "----------\n\n"; echo wptexturize($customer_note) . "\n\n"; echo "----------\n\n"; echo __("For your reference, your order details are shown below.", 'woocommerce') . "\n\n"; echo "****************************************************\n\n"; do_action('woocommerce_email_before_order_table', $order, false); echo sprintf(__('Order number: %s', 'woocommerce'), $order->get_order_number()) . "\n"; echo sprintf(__('Order date: %s', 'woocommerce'), date_i18n(woocommerce_date_format(), strtotime($order->order_date))) . "\n"; do_action('woocommerce_email_order_meta', $order, false, true); echo "\n" . $order->email_order_items_table($order->is_download_permitted(), true, '', '', '', true); echo "----------\n\n"; if ($totals = $order->get_order_item_totals()) { foreach ($totals as $total) { echo $total['label'] . "\t " . $total['value'] . "\n"; } } echo "\n****************************************************\n\n"; do_action('woocommerce_email_after_order_table', $order, false, true); echo __('Your details', 'woocommerce') . "\n\n"; if ($order->billing_email) { echo __('Email:', 'woocommerce'); } echo $order->billing_email . "\n";
<th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('End Date', 'woocommerce-subscriptions'); ?> </th> </tr> </thead> <tbody> <?php foreach ($order->get_items() as $item) { if (WC_Subscriptions_Order::is_item_subscription($order, $item)) { ?> <tr> <td scope="row" style="text-align:left; border: 1px solid #eee;"><?php echo $item['name']; ?> </td> <td scope="row" style="text-align:left; border: 1px solid #eee;"><?php echo date_i18n(woocommerce_date_format(), strtotime($item['subscription_start_date'])); ?> </td> <td scope="row" style="text-align:left; border: 1px solid #eee;"><?php echo !empty($item['subscription_expiry_date']) ? date_i18n(woocommerce_date_format(), strtotime($item['subscription_expiry_date'])) : __('When Cancelled', 'woocommerce-subscriptions'); ?> </tr> <?php } } ?> </tbody> </table>
/** * Add the next payment date to the end of the subscription to clarify when the new rate will be charged * * @since 1.4 */ public static function customise_subscription_price_string($subscription_string) { $switch_details = self::cart_contains_subscription_switch(); if (false !== $switch_details && 0 != $switch_details['first_payment_timestamp']) { $subscription_string = sprintf(__('%s %s(next payment %s)%s', 'woocommerce-subscriptions'), $subscription_string, '<small>', date_i18n(woocommerce_date_format(), $switch_details['first_payment_timestamp']), '</small>'); } return $subscription_string; }
/** * Return a string explaining when the first payment will be completed for the subscription. * * @since 1.5 */ public static function get_products_first_payment_date($product) { $first_payment_date = ''; if (self::is_product_synced($product)) { $first_payment_timestamp = self::calculate_first_payment_date($product->id, 'timestamp'); if (0 != $first_payment_timestamp) { $is_first_payment_today = self::is_today($first_payment_timestamp); if ($is_first_payment_today) { $payment_date_string = __('Today!', 'woocommerce-subscriptions'); } else { $payment_date_string = date_i18n(woocommerce_date_format(), $first_payment_timestamp + get_option('gmt_offset') * HOUR_IN_SECONDS); } if (self::is_product_prorated($product) && !$is_first_payment_today) { $first_payment_date = sprintf(__('First payment prorated. Next payment: %s', 'woocommerce-subscriptions'), $payment_date_string); } else { $first_payment_date = sprintf(__('First payment: %s', 'woocommerce-subscriptions'), $payment_date_string); } $first_payment_date = '<small>' . $first_payment_date . '</small>'; } } return apply_filters('woocommerce_subscriptions_synced_first_payment_date_string', $first_payment_date, $product); }
function apg_sms_procesa_variables($mensaje, $pedido, $variables, $nota = '') { $apg_sms = array("id", "status", "prices_include_tax", "tax_display_cart", "display_totals_ex_tax", "display_cart_ex_tax", "order_date", "modified_date", "customer_message", "customer_note", "post_status", "shop_name", "note", "order_product"); $apg_sms_variables = array("order_key", "billing_first_name", "billing_last_name", "billing_company", "billing_address_1", "billing_address_2", "billing_city", "billing_postcode", "billing_country", "billing_state", "billing_email", "billing_phone", "shipping_first_name", "shipping_last_name", "shipping_company", "shipping_address_1", "shipping_address_2", "shipping_city", "shipping_postcode", "shipping_country", "shipping_state", "shipping_method", "shipping_method_title", "payment_method", "payment_method_title", "order_discount", "cart_discount", "order_tax", "order_shipping", "order_shipping_tax", "order_total"); $variables_personalizadas = explode("\n", str_replace(array("\r\n", "\r"), "\n", $variables)); $variables_de_pedido = get_post_custom($pedido->id); //WooCommerce 2.1 preg_match_all("/%(.*?)%/", $mensaje, $busqueda); foreach ($busqueda[1] as $variable) { $variable = strtolower($variable); if (!in_array($variable, $apg_sms) && !in_array($variable, $apg_sms_variables) && !in_array($variable, $variables_personalizadas)) { continue; } $especiales = array("order_date", "modified_date", "shop_name", "note", "id", "order_product"); if (!in_array($variable, $especiales)) { if (in_array($variable, $apg_sms)) { $mensaje = str_replace("%" . $variable . "%", $pedido->{$variable}, $mensaje); //Variables estándar - Objeto } else { if (in_array($variable, $apg_sms_variables)) { $mensaje = str_replace("%" . $variable . "%", $variables_de_pedido["_" . $variable][0], $mensaje); //Variables estándar - Array } else { if (isset($variables_de_pedido[$variable]) || in_array($variable, $variables_personalizadas)) { $mensaje = str_replace("%" . $variable . "%", $variables_de_pedido[$variable][0], $mensaje); //Variables de pedido y personalizadas } } } } else { if ($variable == "order_date" || $variable == "modified_date") { $mensaje = str_replace("%" . $variable . "%", date_i18n(woocommerce_date_format(), strtotime($pedido->{$variable})), $mensaje); } else { if ($variable == "shop_name") { $mensaje = str_replace("%" . $variable . "%", get_bloginfo('name'), $mensaje); } else { if ($variable == "note") { $mensaje = str_replace("%" . $variable . "%", $nota, $mensaje); } else { if ($variable == "id") { $mensaje = str_replace("%" . $variable . "%", $pedido->get_order_number(), $mensaje); } else { if ($variable == "order_product") { $productos = $pedido->get_items(); $nombre = $productos[key($productos)]['name']; if (strlen($nombre) > 10) { $nombre = substr($nombre, 0, 10) . "..."; } if (count($productos) > 1) { $nombre .= " (+" . (count($productos) - 1) . ")"; } $mensaje = str_replace("%" . $variable . "%", $nombre, $mensaje); } } } } } } } $mensaje = apply_filters('apg_sms_message', $mensaje, $pedido->id); return $mensaje; }
if ('pending' == $order->status) { echo __("Your pre-order is now available, but requires payment. Please pay for your pre-order now : ", WC_Pre_Orders::TEXT_DOMAIN) . esc_url($order->get_checkout_payment_url()) . "\n\n"; } elseif ('failed' == $order->status || 'on-hold' == $order->status) { echo __("Your pre-order is now available, but automatic payment failed. Please update your payment information now : ", WC_Pre_Orders::TEXT_DOMAIN) . esc_url($order->get_checkout_payment_url()) . "\n\n"; } else { echo __("Your pre-order is now available. Your order details are shown below for your reference.", WC_Pre_Orders::TEXT_DOMAIN) . "\n\n"; } if ($message) { echo "----------\n\n"; echo wptexturize($message) . "\n\n"; echo "----------\n\n"; } echo "****************************************************\n\n"; do_action('woocommerce_email_before_order_table', $order, false); echo sprintf(__('Order number: %s', WC_Pre_Orders::TEXT_DOMAIN), $order->get_order_number()) . "\n"; echo sprintf(__('Order date: %s', WC_Pre_Orders::TEXT_DOMAIN), date_i18n(woocommerce_date_format(), strtotime($order->order_date))) . "\n"; do_action('woocommerce_email_order_meta', $order, false, true); echo "\n" . $order->email_order_items_table($order->is_download_permitted(), true, $order->status == 'processing' ? true : false, '', '', true); echo "----------\n\n"; if ($totals = $order->get_order_item_totals()) { foreach ($totals as $total) { echo $total['label'] . "\t " . $total['value'] . "\n"; } } echo "\n****************************************************\n\n"; do_action('woocommerce_email_after_order_table', $order, false, true); echo __('Your details', WC_Pre_Orders::TEXT_DOMAIN) . "\n\n"; if ($order->billing_email) { echo __('Email:', WC_Pre_Orders::TEXT_DOMAIN); } echo $order->billing_email . "\n";
/** * Change a subscription's next payment date. * * @param mixed $new_payment_date Either a MySQL formatted Date/time string or a Unix timestamp. * @param string $subscription_key A subscription key of the form created by @see self::get_subscription_key() * @param int $user_id The id of the user who purchased the subscription * @param string $timezone Either 'server' or 'user' to describe the timezone of the $new_payment_date. * @since 1.2 */ public static function update_next_payment_date($new_payment_date, $subscription_key, $user_id = '', $timezone = 'server') { if (empty($user_id)) { $user_id = self::get_user_id_from_subscription_key($subscription_key); } $next_payment_timestamp = self::get_next_payment_date($subscription_key, $user_id, 'timestamp'); $new_payment_timestamp = is_numeric($new_payment_date) ? $new_payment_date : strtotime($new_payment_date); // Use server time not user time if ('server' != $timezone) { $new_payment_timestamp = $new_payment_timestamp - get_option('gmt_offset') * 3600; } $expiration_timestamp = self::get_subscription_expiration_date($subscription_key, $user_id, 'timestamp'); $trial_expiration_timestamp = self::get_trial_expiration_date($subscription_key, $user_id, 'timestamp'); if (0 == $next_payment_timestamp) { $response = new WP_Error('invalid-date', __('This subscription does not have any future payments.', 'woocommerce-subscriptions')); } elseif ($new_payment_timestamp <= gmdate('U')) { $response = new WP_Error('invalid-date', __('Please enter a date in the future.', 'woocommerce-subscriptions')); } elseif (0 != $trial_expiration_timestamp && $new_payment_timestamp <= $trial_expiration_timestamp) { $response = new WP_Error('invalid-date', sprintf(__('Please enter a date after the trial period ends (%s).', 'woocommerce-subscriptions'), date_i18n(woocommerce_date_format(), $trial_expiration_timestamp + get_option('gmt_offset') * 3600))); } elseif (0 != $expiration_timestamp && $new_payment_timestamp >= $expiration_timestamp) { $response = new WP_Error('invalid-date', __('Please enter a date before the expiration date.', 'woocommerce-subscriptions')); } elseif (self::set_next_payment_date($subscription_key, $user_id, $new_payment_timestamp)) { self::update_wp_cron_lock($subscription_key, $new_payment_timestamp - gmdate('U'), $user_id); $response = $new_payment_timestamp; } else { $response = new WP_Error('misc-error', __('The payment date could not be changed.', 'woocommerce-subscriptions')); } return $response; }
/** * Determine if the email should actually be sent and setup email merge variables * * @since 0.1 * @param int $order_id */ public function trigger($order_id) { global $woocommerce; // bail if no order ID is present if (!$order_id) { return; } // setup order object $this->object = new WC_Order($order_id); //check if is downloadbale if (!$this->object->has_downloadable_item()) { return; } // replace variables in the subject/headings $this->find[] = '{order_date}'; $this->replace[] = date_i18n(woocommerce_date_format(), strtotime($this->object->order_date)); $this->find[] = '{order_number}'; $this->replace[] = $this->object->get_order_number(); //To get the dir, use: dirname($path) require_once 'fpdf/fpdf.php'; require_once 'fpdi/fpdi.php'; if (!$this->is_enabled() || !$this->get_recipient()) { return; } $upload_dir = wp_upload_dir(); // Array of key => value pairs //cosntruct ticket temp dir $tickettemp = $upload_dir['basedir'] . '/tickets_temp'; if (!file_exists($tickettemp)) { mkdir($tickettemp, 0755, true); } $items = $this->object->get_items(); $varation_ids = array(); $metaorder = get_post_meta($this->object->id); $emaailid = $this->object->billing_email; $downloadlinks = array(); $i = 0; foreach ($items as $key => $value) { $x = 1; $getprod = $this->object->get_product_from_item($value); $getdownload = $this->object->get_item_downloads($value); if ($getprod->product_type != 'ticket') { break; } if (empty($getdownload)) { break; } $qty = intval($value['qty']); while ($x <= $qty) { $x++; foreach ($getdownload as $keysub => $valuesub) { $downlink = $valuesub['file']; } $path = $_SERVER['DOCUMENT_ROOT'] . parse_url($downlink, PHP_URL_PATH); $pdfout = $tickettemp . '/ticket_' . $this->object->id . '' . $value['product_id'] . '' . $x . '.pdf'; $downloadlinks[$i] = $pdfout; $pagenum = 1; $pdf = new FPDI(); $pdf->AddPage(); //Set the source PDF file $pagecount = $pdf->setSourceFile($path); //Import the first page of the file $tpl = $pdf->importPage($pagenum); //Use this page as template $pdf->useTemplate($tpl); $getfooterY = $pdf->h - 35; //Select Arial italic 8 $pdf->SetY($getfooterY); $pdf->SetFont('Arial', 'I', 10); $pdf->Cell(0, 10, 'Ticket id: ' . $this->object->id . '' . $value['product_id'] . '' . $x, 0, 0, 'C'); $pdf->Output($pdfout, "F"); $i++; } } /* $email_class = new WC_Email(); remove_action( 'woocommerce_after_resend_order_email', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); remove_action( 'woocommerce_order_status_completed_notification', array( $email_class->emails['WC_Email_Customer_Completed_Order'], 'trigger' ) ); echo "<pre>"; var_dump( $this->emails ); echo "</pre>"; var_dump( $downloadlinks ); var_dump( $items ); var_dump( $emaailid); var_dump( $this->object ); */ // woohoo, send the email! $this->send($this->get_recipient() . ', ' . $this->object->billing_email, $this->get_subject(), $this->get_content(), $this->get_headers(), $downloadlinks); //Delete the temp tickets foreach ($downloadlinks as $key => $value) { chmod($value, 0777); if (file_exists($value)) { unlink($value); } } //die(); }
/** * Outputs the content for each column. * * @param array $item A singular item (one full row's worth of data) * @param array $column_name The name/slug of the column to be processed * @return string Text or HTML to be placed inside the column <td> * @since 1.0 */ public function column_default($item, $column_name) { global $woocommerce; $current_gmt_time = gmdate('U'); $column_content = ''; switch ($column_name) { case 'status': $actions = array(); $action_url = add_query_arg(array('page' => $_REQUEST['page'], 'user' => $item['user_id'], 'subscription' => $item['subscription_key'], '_wpnonce' => wp_create_nonce($item['subscription_key']))); if (isset($_REQUEST['status'])) { $action_url = add_query_arg(array('status' => $_REQUEST['status']), $action_url); } $order = new WC_Order($item['order_id']); $all_statuses = array('active' => __('Reactivate', 'woocommerce-subscriptions'), 'on-hold' => __('Suspend', 'woocommerce-subscriptions'), 'cancelled' => __('Cancel', 'woocommerce-subscriptions'), 'trash' => __('Trash', 'woocommerce-subscriptions'), 'deleted' => __('Delete Permanently', 'woocommerce-subscriptions')); foreach ($all_statuses as $status => $label) { if (WC_Subscriptions_Manager::can_subscription_be_changed_to($status, $item['subscription_key'], $item['user_id'])) { $action = 'deleted' == $status ? 'delete' : $status; // For built in CSS $actions[$action] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg('new_status', $status, $action_url)), $label); } } if ($item['status'] == 'pending') { unset($actions['active']); unset($actions['trash']); } elseif (!in_array($item['status'], array('cancelled', 'expired', 'switched', 'suspended'))) { unset($actions['trash']); } $actions = apply_filters('woocommerce_subscriptions_list_table_actions', $actions, $item); $column_content = sprintf('<mark class="%s">%s</mark> %s', sanitize_title($item[$column_name]), WC_Subscriptions_Manager::get_status_to_display($item[$column_name], $item['subscription_key'], $item['user_id']), $this->row_actions($actions)); $column_content = apply_filters('woocommerce_subscriptions_list_table_column_status_content', $column_content, $item, $actions, $this); break; case 'title': //Return the title contents $column_content = sprintf('<a href="%s">%s</a>', get_edit_post_link($item['product_id']), WC_Subscriptions_Order::get_item_name($item['order_id'], $item['product_id'])); $order = new WC_Order($item['order_id']); $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $item['product_id']); $product = $order->get_product_from_item($order_item); if (isset($product->variation_data)) { $column_content .= '<br />' . woocommerce_get_formatted_variation($product->variation_data, true); } break; case 'order_id': $order = new WC_Order($item[$column_name]); $column_content = sprintf('<a href="%1$s">%2$s</a>', get_edit_post_link($item[$column_name]), sprintf(__('Order %s', 'woocommerce-subscriptions'), $order->get_order_number())); break; case 'user': $user = get_user_by('id', $item['user_id']); if (is_object($user)) { $column_content = sprintf('<a href="%s">%s</a>', admin_url('user-edit.php?user_id=' . $user->ID), ucfirst($user->display_name)); } break; case 'start_date': case 'expiry_date': case 'end_date': if ($column_name == 'expiry_date' && $item[$column_name] == 0) { $column_content = __('Never', 'woocommerce-subscriptions'); } else { if ($column_name == 'end_date' && $item[$column_name] == 0) { $column_content = __('Not yet ended', 'woocommerce-subscriptions'); } else { $gmt_timestamp = strtotime($item[$column_name]); $user_timestamp = $gmt_timestamp + get_option('gmt_offset') * 3600; $column_content = sprintf('<time>%s</time>', date_i18n(woocommerce_date_format(), $user_timestamp)); } } break; case 'trial_expiry_date': $trial_expiration = WC_Subscriptions_Manager::get_trial_expiration_date($item['subscription_key'], $item['user_id'], 'timestamp'); if (empty($trial_expiration)) { $column_content = '-'; } else { $column_content = sprintf('<time title="%s">%s</time>', esc_attr($trial_expiration), date_i18n(woocommerce_date_format(), $trial_expiration + get_option('gmt_offset') * 3600)); } break; case 'last_payment_date': // Although we record the sign-up date as a payment, if there is a free trial and no sign-up fee, no payment is actually charged if (0 == WC_Subscriptions_Order::get_total_initial_payment($item['order_id']) && 1 == count($item['completed_payments'])) { $column_content = '-'; } else { $last_payment_timestamp = strtotime($item['last_payment_date']); $time_diff = $current_gmt_time - $last_payment_timestamp; if ($time_diff > 0 && $time_diff < 7 * 24 * 60 * 60) { $last_payment = sprintf(__('%s ago', 'woocommerce-subscriptions'), human_time_diff($last_payment_timestamp, $current_gmt_time)); } else { $last_payment = date_i18n(woocommerce_date_format(), $last_payment_timestamp + get_option('gmt_offset') * 3600); } $column_content = sprintf('<time title="%s">%s</time>', esc_attr($last_payment_timestamp), $last_payment); } break; case 'next_payment_date': $next_payment_timestamp_gmt = WC_Subscriptions_Manager::get_next_payment_date($item['subscription_key'], $item['user_id'], 'timestamp'); $next_payment_timestamp = $next_payment_timestamp_gmt + get_option('gmt_offset') * 3600; if ($next_payment_timestamp_gmt == 0) { $column_content = '-'; } else { // Convert to site time $time_diff = $next_payment_timestamp_gmt - $current_gmt_time; if ($time_diff > 0 && $time_diff < 7 * 24 * 60 * 60) { $next_payment = sprintf(__('In %s', 'woocommerce-subscriptions'), human_time_diff($current_gmt_time, $next_payment_timestamp_gmt)); } else { $next_payment = date_i18n(woocommerce_date_format(), $next_payment_timestamp); } $column_content = sprintf('<time class="next-payment-date" title="%s">%s</time>', esc_attr($next_payment_timestamp), $next_payment); if (WC_Subscriptions_Manager::can_subscription_be_changed_to('new-payment-date', $item['subscription_key'], $item['user_id'])) { $column_content .= '<div class="edit-date-div row-actions hide-if-no-js">'; $column_content .= '<img class="date-picker-icon" src="' . admin_url('images/date-button.gif') . '" title="' . __('Date Picker Icon', 'woocommerce-subscriptions') . '" />'; $column_content .= '<a href="#edit_timestamp" class="edit-timestamp" tabindex="4">' . __('Change', 'woocommerce-subscriptions') . '</a>'; $column_content .= '<div class="date-picker-div hide-if-js">'; $column_content .= WC_Subscriptions_Manager::touch_time(array('date' => date('Y-m-d', $next_payment_timestamp), 'echo' => false, 'multiple' => true, 'include_time' => false)); $column_content .= '</div>'; $column_content .= '</div>'; } } break; case 'renewal_order_count': $count = WC_Subscriptions_Renewal_Order::get_renewal_order_count($item['order_id']); $column_content = sprintf('<a href="%1$s">%2$d</a>', admin_url('edit.php?post_status=all&post_type=shop_order&_renewal_order_parent_id=' . absint($item['order_id'])), $count); break; } return apply_filters('woocommerce_subscriptions_list_table_column_content', $column_content, $item, $column_name); }
/** * Compatibility for the woocommerce_date_format() function which is soft-deprecated in 2.1+ * * @since 2.0 * @return string date format */ public static function wc_date_format() { return self::is_wc_version_gte_2_1() ? wc_date_format() : woocommerce_date_format(); }
/** * get_content_plain function. * * @access public * @return string */ function get_content_plain() { $order = new WC_Order($this->object['order_id']); $item_name = WC_Subscriptions_Order::get_item_name($this->object['order_id'], $this->object['product_id']); $order_item = WC_Subscriptions_Order::get_item_by_product_id($order, $this->object['product_id']); $product = $order->get_product_from_item($order_item); if (isset($product->variation_data)) { $item_name .= ' (' . woocommerce_get_formatted_variation($product->variation_data, true) . ')'; } WC_Subscriptions_Order::$recurring_only_price_strings = true; $recurring_total = WC_Subscriptions_Order::get_formatted_order_total(0, $order); WC_Subscriptions_Order::$recurring_only_price_strings = false; if ($end_of_prepaid_term = wp_next_scheduled('scheduled_subscription_end_of_prepaid_term', array('user_id' => (int) $order->user_id, 'subscription_key' => $this->subscription_key))) { $end_of_prepaid_term = date_i18n(woocommerce_date_format(), $end_of_prepaid_term + get_option('gmt_offset') * 3600); } ob_start(); woocommerce_get_template($this->template_plain, array('subscription_key' => $this->subscription_key, 'subscription' => $this->object, 'order' => $order, 'email_heading' => $this->get_heading(), 'item_name' => $item_name, 'recurring_total' => $recurring_total, 'last_payment' => date_i18n(woocommerce_date_format(), WC_Subscriptions_Manager::get_last_payment_date($this->subscription_key, '', 'timestamp')), 'end_of_prepaid_term' => $end_of_prepaid_term), '', $this->template_base); return ob_get_clean(); }
/** * Append the first renewal payment date to a string (which is the order total HTML string by default) * * @access public * @return string */ function wcs_add_cart_first_renewal_payment_date($order_total_html, $cart) { if (0 !== $cart->next_payment_date) { $first_renewal_date = date_i18n(woocommerce_date_format(), strtotime(get_date_from_gmt($cart->next_payment_date))); // translators: placeholder is a date $order_total_html .= '<div class="first-payment-date"><small>' . sprintf(__('First renewal: %s', 'woocommerce-subscriptions'), $first_renewal_date) . '</small></div>'; } return $order_total_html; }
?> <?php } else { // In the past ?> <?php $expiry = sprintf(__('%s ago', 'woocommerce-subscriptions'), human_time_diff($end_timestamp)); ?> <?php } ?> <?php } else { ?> <?php $expiry = date_i18n(woocommerce_date_format(), $end_timestamp); ?> <?php } ?> <time title="<?php echo esc_attr($end_timestamp); ?> "> <?php echo $expiry; ?> </time> <?php } ?>
/** * Gets point log entries based on $args * * @since 1.0 * @param array $args the query arguments * @return array of log entry objects */ public static function get_points_log_entries($args) { global $wc_points_rewards, $wpdb; // special handling for searching by user if (!empty($args['user'])) { $args['where'][] = $wpdb->prepare("{$wc_points_rewards->user_points_log_db_tablename}.user_id = %s", $args['user']); } // special handling for searching by event type if (!empty($args['event_type'])) { $args['where'][] = $wpdb->prepare("{$wc_points_rewards->user_points_log_db_tablename}.type = %s", $args['event_type']); } $entries = array(); foreach (self::query($args) as $log_entry) { // maybe unserialize the arbitrary data object $log_entry->data = maybe_unserialize($log_entry->data); // Format the event date as "15 minutes ago" if the event took place in the last 24 hours, otherwise just show the date (timestamp on mouse hover) $timestamp = strtotime($log_entry->date); $t_time = date_i18n('Y/m/d g:i:s A', $timestamp); $time_diff = current_time('timestamp', true) - $timestamp; if ($time_diff > 0 && $time_diff < 24 * 60 * 60) { $h_time = sprintf(__('%s ago', 'wc_points_rewards'), human_time_diff($timestamp, current_time('timestamp', true))); } else { $h_time = date_i18n(woocommerce_date_format(), $timestamp); } $log_entry->date_display_human = $h_time; $log_entry->date_display = $t_time; // retrieve the description $log_entry->description = WC_Points_Rewards_Manager::event_type_description($log_entry->type, $log_entry); $entries[] = $log_entry; } return $entries; }
?> </p> <?php } ?> <?php do_action('woocommerce_email_before_order_table', $order, false); ?> <h2><?php echo __('Order:', 'woocommerce') . ' ' . $order->get_order_number(); ?> (<?php printf('<time datetime="%s">%s</time>', date_i18n('c', strtotime($order->order_date)), date_i18n(woocommerce_date_format(), strtotime($order->order_date))); ?> )</h2> <table cellspacing="0" cellpadding="6" style="width: 100%; border: 1px solid #eee;" border="1" bordercolor="#eee"> <thead> <tr> <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Product', 'woocommerce'); ?> </th> <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php _e('Quantity', 'woocommerce'); ?> </th> <th scope="col" style="text-align:left; border: 1px solid #eee;"><?php
/** * Gets the availability date of the product localized to the site's date format * * @since 1.0 * @param object|int $product preferably the product object, or product ID if object is inconvenient to provide * @param string $none_text optional text to return if there is no availability datetime set * @return string the formatted availability date */ public static function get_localized_availability_date($product, $none_text = '') { if ('' === $none_text) { $none_text = __('Soon', WC_Pre_Orders::TEXT_DOMAIN); } if (!is_object($product)) { $product = get_product($product); } $timestamp = self::get_localized_availability_datetime_timestamp($product); if (!$timestamp) { return $none_text; } return apply_filters('wc_pre_orders_localized_availability_date', date_i18n(woocommerce_date_format(), $timestamp), $product, $none_text); }