public function emailShortcodes($attrs) { $output = ''; if ($attrs['source'] == 'receipt' || $attrs['source'] == 'fulfillment' || $attrs['source'] == 'status' || $attrs['source'] == 'followup') { $order = new Cart66Order($attrs['id']); $data = array('bill_first_name', 'bill_last_name', 'bill_address', 'bill_address2', 'bill_city', 'bill_state', 'bill_country', 'bill_zip', 'ship_first_name', 'ship_last_name', 'ship_address', 'ship_address2', 'ship_city', 'ship_state', 'ship_country', 'ship_zip', 'phone', 'email', 'coupon', 'discount_amount', 'trans_id', 'shipping', 'subtotal', 'tax', 'total', 'non_subscription_total', 'custom_field', 'ordered_on', 'status', 'ip', 'products', 'fulfillment_products', 'receipt', 'receipt_link', 'ouid', 'shipping_method', 'account_id', 'tracking_number', 'feature_level', 'subscription_plan_name', 'active_until', 'billing_interval', 'username'); if (in_array($attrs['att'], $data)) { switch ($attrs['att']) { case 'bill_first_name': // Intentional falling through // Intentional falling through case 'bill_last_name': case 'ship_first_name': case 'ship_last_name': $output = ucfirst(strtolower($order->{$attrs}['att'])); break; case 'bill_address': if ($order->bill_address2 != '') { $output = $order->{$attrs}['att'] . '<br />' . $order->bill_address2; } else { $output = $order->{$attrs}['att']; } break; case 'ship_address': if ($order->ship_address2 != '') { $output = $order->{$attrs}['att'] . '<br />' . $order->ship_address2; } else { $output = $order->{$attrs}['att']; } break; case 'products': $output = Cart66Common::getView('/pro/views/emails/email-products.php', array('order' => $order, 'type' => $attrs['type'], 'code' => 'products')); break; case 'fulfillment_products': $output = Cart66Common::getView('/pro/views/emails/email-products.php', array('order' => $order, 'type' => $attrs['type'], 'code' => 'fulfillment_products', 'variable' => $attrs['variable'])); break; case 'receipt': $output = Cart66Common::getView('/pro/views/emails/email-receipt.php', array('order' => $order, 'type' => $attrs['type'])); break; case 'phone': $output = Cart66Common::formatPhone($order->{$attrs}['att']); break; case 'total': $output = Cart66Common::currency($order->{$attrs}['att'], false); break; case 'tax': $output = Cart66Common::currency($order->{$attrs}['att'], false); break; case 'receipt_link': $receiptPage = get_page_by_path('store/receipt'); $link = get_permalink($receiptPage->ID); if (strstr($link, "?")) { $link .= '&ouid='; } else { $link .= '?ouid='; } $output = $link . $order->ouid; break; case 'feature_level': // Intentionally falling through // Intentionally falling through case 'active_until': case 'subscription_plan_name': case 'active_until': case 'active_until': case 'billing_interval': if ($order->account_id) { $sub = new Cart66AccountSubscription($order->account_id); $output = $sub->{$attrs}['att']; } else { $output = "None"; } break; case 'username': if ($order->account_id) { $sub = new Cart66AccountSubscription($order->account_id); $account = new Cart66Account(); $account->load($sub->account_id); //Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Loaded account: " . print_r($account, true) ); $output = $account->{$attrs}['att']; } else { $output = "None"; } break; default: $output = $order->{$attrs}['att']; } } elseif (substr($attrs['att'], 0, 8) == 'tracking') { $output = Cart66AdvancedNotifications::updateTracking($order, $attrs); } elseif (substr($attrs['att'], 0, 5) == 'date:') { $output = Cart66AdvancedNotifications::updateDate($attrs); } elseif (substr($attrs['att'], 0, 12) == 'date_ordered') { $output = Cart66AdvancedNotifications::updateDateOrdered($order, $attrs); } $shipping_options = array('ship_first_name', 'ship_last_name', 'ship_address', 'ship_address2', 'ship_city', 'ship_state', 'ship_country', 'ship_zip'); if (in_array($attrs['att'], $shipping_options) && $order->shipping_method == 'None') { $output = ''; } } elseif ($attrs['source'] == 'reminder') { $sub = new Cart66AccountSubscription($attrs['id']); $account = new Cart66Account(); $account->load($sub->account_id); $data = array('billing_first_name', 'billing_last_name', 'feature_level', 'subscription_plan_name', 'active_until', 'billing_interval', 'username', 'opt_out_link'); if (in_array($attrs['att'], $data)) { switch ($attrs['att']) { case 'billing_first_name': // Intentional falling through // Intentional falling through case 'billing_last_name': $output = ucfirst(strtolower($sub->{$attrs}['att'])); break; case 'active_until': $output = date(get_option('date_format'), strtotime($sub->{$attrs}['att'])); break; case 'username': $output = $account->{$attrs}['att']; break; case 'opt_out_link': $output = Cart66ProCommon::generateUnsubscribeLink($account->id); break; default: $output = $sub->{$attrs}['att']; } } } Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] output: {$output}"); return $output; }