當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Page_Controller::getNonExpiringIsProductId方法代碼示例

本文整理匯總了PHP中Page_Controller::getNonExpiringIsProductId方法的典型用法代碼示例。如果您正苦於以下問題:PHP Page_Controller::getNonExpiringIsProductId方法的具體用法?PHP Page_Controller::getNonExpiringIsProductId怎麽用?PHP Page_Controller::getNonExpiringIsProductId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Page_Controller的用法示例。


在下文中一共展示了Page_Controller::getNonExpiringIsProductId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createSubscription

 public function createSubscription($data, $form)
 {
     //Get member id
     $memberId = $data['MemberID'];
     //Get product id
     $productId = $data['ProductID'];
     // Get the Page controller
     $Page_Ctrl = new Page_Controller();
     //Get InfusionSoft Api
     $app = $Page_Ctrl->getInfusionSoftApi();
     // Get curent date
     $curdate = $app->infuDate(date('j-n-Y'));
     $member = Member::get()->byID($memberId);
     //Find or create the 'user' group and add the member to the group
     if (!($userGroup = DataObject::get_one('Group', "Code = 'customers'"))) {
         $userGroup = new Group();
         $userGroup->Code = "customers";
         $userGroup->Title = "Customers";
         $userGroup->Write();
         $userGroup->Members()->add($member);
     } else {
         $userGroup->Members()->add($member);
     }
     $isConID = $member->ISContactID;
     $product = Product::get()->byID($productId);
     // Get existing credit card ID
     $creditCard = $Page_Ctrl->getCurrentCreditCard($memberId);
     // Get the current InfusionSoft credit card ID
     $ccID = $creditCard->ISCCID;
     //Get siteconfig object
     $config = SiteConfig::current_site_config();
     //Process non-expiring heatmaps purchase
     if ($productId == 4 || $productId == 5 || $productId == 6 || $productId == 7) {
         if (!$data['Quantity']) {
             $form->addErrorMessage('Quantity', "Quantity is required for non-expiring products.", 'bad');
             return $this->edit(Controller::curr()->getRequest());
         }
         // Create an Infusionsoft order
         $invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
         $orderItem = $app->addOrderItem($invoiceId, intval($Page_Ctrl->getNonExpiringIsProductId($data['ProductID'])), 3, floatval($product->Price), intval($data['Quantity']), $product->Name, $product->Name);
         $result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
         // Create an order
         $order = new Order();
         $order->OrderStatus = 'P';
         $order->Amount = $product->Price * $data['Quantity'];
         $order->MemberID = $member->ID;
         $order->ProductID = $data['ProductID'];
         $order->CreditCardID = $creditCard->ID;
         $orderID = $order->write();
         if ($result['Successful']) {
             // Add tag Paid member - prepaid
             $app->grpAssign($isConID, 2290);
             $conDat = array('ContactType' => 'AW Customer');
             $returnFields = array('_AttentionWizard');
             $conDat1 = $app->loadCon($isConID, $returnFields);
             if (isset($conDat1['_AttentionWizard']) && $conDat1['_AttentionWizard'] != 'Paid and Current' && $conDat1['_AttentionWizard'] != 'Free') {
                 $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
             }
             if (!isset($conDat1['_AttentionWizard'])) {
                 $conDat['_AttentionWizard'] = 'Prepaid only - no subscription';
             }
             $conID = $app->updateCon($isConID, $conDat);
             // Note is added
             $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Purchased AW Prepaid Credits", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
             $conActionID = $app->dsAdd("ContactAction", $conActionDat);
             // Update order
             $order->OrderStatus = 'c';
             $order->write();
             // Create a Subscription record
             $subscription = new Subscription();
             $subscription->StartDate = date("Y-m-d H:i:s");
             $subscription->MemberID = $member->ID;
             $subscription->ProductID = $data['ProductID'];
             $subscription->OrderID = $orderID;
             $subscription->write();
             // Create a MemberCredits record
             $memberCredits = new MemberCredits();
             $memberCredits->Credits = $product->Credits * $data['Quantity'];
             $memberCredits->MemberID = $member->ID;
             $memberCredits->ProductID = $product->ID;
             $memberCredits->SubscriptionID = $subscription->ID;
             $memberCredits->write();
             $form->sessionMessage("Purchased non-expiring heatmaps successfully.", 'good');
             return Controller::curr()->redirect("admin/manage-data/Subscription/EditForm/field/Subscription/item/{$subscription->ID}/edit");
         } else {
             // Add an AW prospect tag
             $app->grpAssign($isConID, $Page_Ctrl->getISTagIdByPaymentCode(strtoupper($result['Code'])));
             // Add a note
             $conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Unsuccessful attempt to purchase prepaid plan", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'UserID' => 1);
             $conActionID = $app->dsAdd("ContactAction", $conActionDat);
             $form->sessionMessage("Sorry,the payment failed,please update the user credit card.", 'bad');
             return $this->edit(Controller::curr()->getRequest());
         }
     }
     //Process subscriptions
     if ($productId == 1 || $productId == 2 || $productId == 3) {
         $credits = $product->Credits;
         $subscriptionID = $Page_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
         if ($subscriptionID && is_int($subscriptionID)) {
             if ($productId == 1 && !$Page_Ctrl->isCCUsedForTrial($creditCard->CreditCardNumber)) {
//.........這裏部分代碼省略.........
開發者ID:hemant-chakka,項目名稱:awss,代碼行數:101,代碼來源:DataAdmin.php


注:本文中的Page_Controller::getNonExpiringIsProductId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。