PATH:
home
/
letacommog
/
laindinois
/
wp-content
/
plugins
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Payment\Coupon; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Framework\Store\Session; use \WilokeListingTools\Models\Coupon as CouponModel; class CouponController extends Controller { protected $planID; public function __construct() { add_action('wp_ajax_nopriv_wiloke_submission_verify_coupon', [$this, 'verifyCoupon']); add_action('wp_ajax_wiloke_submission_verify_coupon', [$this, 'verifyCoupon']); } public function verifyCoupon() { $this->planID = Session::getSession(wilokeListingToolsRepository()->get('payment:storePlanID')); $planPostType = get_post_field('post_type', $this->planID); $aPackageInfo = GetSettings::getPlanSettings($this->planID); $subTotal = $aPackageInfo['regular_price']; $aErrMsg = [ 'msg' => \WilokeMessage::message([ 'msg' => esc_html__('The coupon is invalid or has expired', 'wiloke-listing-tools'), 'status' => 'danger' ], true) ]; if (!isset($_POST['code']) || empty($_POST['code'])) { wp_send_json_error($aErrMsg); } $instCoupon = new Coupon(); if (!$instCoupon->getCouponID($_POST['code'])) { wp_send_json_error($aErrMsg); } $instCoupon->getCouponInfo(); if ($instCoupon->isCouponExpired()) { wp_send_json_error($aErrMsg); } if (!$instCoupon->isPostTypeSupported($planPostType)) { wp_send_json_error($aErrMsg); } if ($instCoupon->aSettings['type'] == 'percentage') { $discountPrice = round(($subTotal * $instCoupon->aSettings['amount']) / 100, 2); } else { $discountPrice = $instCoupon->aSettings['amount']; } $taxRate = GetWilokeSubmission::getTaxRate(); if ($subTotal < $discountPrice) { $subTotal = 0; $aMessage = \WilokeMessage::message([ 'msg' => sprintf(__('You save %s', 'wiloke-listing-tools'), GetWilokeSubmission::renderPrice($price)) ], true); $tax = 0; $newTotal = 0; } else { $aMessage = \WilokeMessage::message([ 'msg' => sprintf(__('You save %s', 'wiloke-listing-tools'), GetWilokeSubmission::renderPrice($discountPrice)) ], true); $tax = round(($subTotal - $discountPrice) * $taxRate / 100, 2); $newTotal = round(($tax + $subTotal - $discountPrice), 2); } wp_send_json_success( [ 'msg' => $aMessage, 'subTotal' => $subTotal, 'tax' => $tax, 'discount' => GetWilokeSubmission::renderPrice($discountPrice), 'total' => GetWilokeSubmission::renderPrice($newTotal) ] ); } }
[+]
..
[-] WebhookController.php
[edit]
[-] SetCoupon.php
[edit]
[-] TermController.php
[edit]
[-] PostController.php
[edit]
[-] SetMyPosts.php
[edit]
[-] NotificationsController.php
[edit]
[-] AjaxUploadImgController.php
[edit]
[-] TaxonomiesControllers.php
[edit]
[-] FavoriteStatisticController.php
[edit]
[-] BelongsToCustomTaxonomies.php
[edit]
[-] DashboardController.php
[edit]
[-] ModifyQueryController.php
[edit]
[-] SetCustomGroup.php
[edit]
[+]
Map
[-] TraitHostedBy.php
[edit]
[-] SearchFormController.php
[edit]
[-] InsertFeaturedImg.php
[edit]
[-] PaymentGatewaysController.php
[edit]
[-] PaymentController.php
[edit]
[-] DokanController.php
[edit]
[-] SchemaController.php
[edit]
[-] UserController.php
[edit]
[-] BelongsToLocation.php
[edit]
[-] WooCommerceBookingController.php
[edit]
[-] IsMyPaymentID.php
[edit]
[-] StripeController.php
[edit]
[-] ContactFormController.php
[edit]
[-] AddListingButtonController.php
[edit]
[-] Validation.php
[edit]
[-] GalleryController.php
[edit]
[-] SetListingRelationship.php
[edit]
[-] AddListingController.php
[edit]
[-] MergingSettingValues.php
[edit]
[-] GoogleReCaptchaController.php
[edit]
[-] CouponController.php
[edit]
[-] InvoiceController.php
[edit]
[-] SingleJsonSkeleton.php
[edit]
[-] SingleController.php
[edit]
[-] InsertImg.php
[edit]
[-] EmailController.php
[edit]
[-] BelongsToCategories.php
[edit]
[-] ReviewController.php
[edit]
[-] SetSinglePrice.php
[edit]
[-] PrintSidebarItems.php
[edit]
[-] SetPlanRelationship.php
[edit]
[-] BookingComController.php
[edit]
[-] WooCommerceController.php
[edit]
[-] FacebookLoginController.php
[edit]
[-] EventController.php
[edit]
[-] SetRestaurantMenu.php
[edit]
[-] SetProductsToListing.php
[edit]
[-] UserPlanController.php
[edit]
[-] FollowController.php
[edit]
[+]
Retrieve
[-] SetGeneral.php
[edit]
[-] VerifyPurchaseCode.php
[edit]
[-] PlanRelationshipController.php
[edit]
[-] FreePlanController.php
[edit]
[-] AddBookingComBannerCreator.php
[edit]
[-] ReportController.php
[edit]
[-] RetrieveController.php
[edit]
[-] SetCustomButton.php
[edit]
[-] GetWilokeToolSettings.php
[edit]
[-] PaymentMetaController.php
[edit]
[-] RegisterLoginController.php
[edit]
[-] TermsAndPolicyController.php
[edit]
[-] AppleLoginController.php
[edit]
[-] ChangePlanStatusController.php
[edit]
[-] NextBillingPaymentController.php
[edit]
[-] AddListingPaymentController.php
[edit]
[-] PromotionController.php
[edit]
[-] PrintAddListingSettings.php
[edit]
[-] PayPalExecuteAddListingPayment.php
[edit]
[-] ClaimController.php
[edit]
[-] ViewStatisticController.php
[edit]
[-] SessionController.php
[edit]
[-] SharesStatisticController.php
[edit]
[-] TraitSetEventData.php
[edit]
[-] PrintAddListingFields.php
[edit]
[-] GuardController.php
[edit]
[+]
TransformAddListingData
[-] MessageController.php
[edit]
[-] OptimizeScripts.php
[edit]
[-] InsertLogo.php
[edit]
[-] SetPostDuration.php
[edit]
[-] GridItemController.php
[edit]
[-] SetVideo.php
[edit]
[-] AddMorePhotosVideosController.php
[edit]
[-] TraitAddListingSettings.php
[edit]
[-] InsertGallery.php
[edit]
[-] BillingControllers.php
[edit]
[-] GetSingleImage.php
[edit]
[-] BelongsToTags.php
[edit]
[-] PermalinksController.php
[edit]
[-] RunUpdateDBToLatestVersionController.php
[edit]
[-] SetListingBelongsToPlanID.php
[edit]
[-] NoticeController.php
[edit]
[-] DirectBankTransferController.php
[edit]
[-] SetPriceRange.php
[edit]
[-] TagsBelongsToCatController.php
[edit]
[-] PayPalController.php
[edit]
[-] InsertAddress.php
[edit]
[-] MapListingController.php
[edit]
[-] ListingController.php
[edit]
[-] AuthorPageController.php
[edit]
[-] RestaurantMenuController.php
[edit]
[-] PaymentStatusController.php
[edit]
[-] SetSocialNetworks.php
[edit]
[-] SetCustomSections.php
[edit]
[-] TranslationController.php
[edit]
[-] IconController.php
[edit]
[-] SetGroupData.php
[edit]
[-] SetContactInfo.php
[edit]
[-] ProfileController.php
[edit]
[-] ShareController.php
[edit]
[-] InsertCoverImage.php
[edit]
[-] HandleSubmit.php
[edit]
[-] SetMyRoom.php
[edit]
[-] ModalController.php
[edit]