Skip to content

Commit

Permalink
subscribe done
Browse files Browse the repository at this point in the history
  • Loading branch information
josephlausf committed Feb 19, 2016
1 parent fb4761c commit 76bfae5
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Bento/ViewController/Order/CompleteOrderViewController.m"
timestampString = "477612402.140892"
timestampString = "477617380.66686"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "159"
endingLineNumber = "159"
landmarkName = "-viewDidLoad"
startingLineNumber = "1882"
endingLineNumber = "1882"
landmarkName = "-buildRequest:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
Expand Down
16 changes: 8 additions & 8 deletions Bento/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1436,13 +1436,6 @@
<color key="textColor" red="0.4039215686" green="0.44705882349999998" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="$2.25" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="apF-d2-fYi">
<rect key="frame" x="183" y="7" width="60" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="12"/>
<color key="textColor" red="0.9155273438" green="0.49854745340000001" blue="0.34104120989999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
Expand Down Expand Up @@ -1530,12 +1523,19 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="$2...." textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="jf1-R6-9fd">
<rect key="frame" x="205" y="7" width="100" height="21"/>
<rect key="frame" x="241" y="7" width="64" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="OpenSans" family="Open Sans" pointSize="12"/>
<color key="textColor" red="0.4039215686" green="0.44705882349999998" blue="0.50196078430000002" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="$2.25" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="apF-d2-fYi">
<rect key="frame" x="183" y="7" width="60" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" name="OpenSans-Semibold" family="Open Sans" pointSize="12"/>
<color key="textColor" red="0.9155273438" green="0.49854745340000001" blue="0.34104120989999998" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
</view>
Expand Down
51 changes: 46 additions & 5 deletions Bento/ViewController/Order/CompleteOrderViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ - (BOOL)applePayEnabled
- (void)viewDidLoad {
[super viewDidLoad];

NSDictionary *userInfo = [[DataManager shareDataManager] getUserInfo];
NSLog(@"user info - %i", [userInfo[@"has_oa_subscription"] boolValue]);

allowCommitOnKeep = YES;

// Mixpanel track for Placed An Order
Expand Down Expand Up @@ -673,6 +670,15 @@ - (void)updatePromoView

#pragma mark Calculations

- (BOOL)isSubscribedToOA {
NSDictionary *userInfo = [[DataManager shareDataManager] getUserInfo];
if (userInfo[@"has_oa_subscription"] == nil) {
return NO;
}

return [userInfo[@"has_oa_subscription"] boolValue];
}

// works for x.xxxxxxxx
- (float)roundToNearestHundredth:(float)originalNumber {
originalNumber += 0.005;
Expand Down Expand Up @@ -707,6 +713,12 @@ - (float)getTotalPriceByMainPlusDeliveryFee {
return [self getTotalPriceByMain] + [[BentoShop sharedInstance] getDeliveryPrice];
}

// OA

if ([self isSubscribedToOA]) {
return [self getTotalPriceByMain] + 0;
}

return [self getTotalPriceByMain] + [self.orderAheadMenu.deliveryPrice floatValue];
}

Expand Down Expand Up @@ -773,7 +785,12 @@ - (void)updatePriceLabels
self.lblDeliveryPrice.text = [NSString stringWithFormat:@"$%.2f", [[BentoShop sharedInstance] getDeliveryPrice]];
}
else if (self.orderMode == OrderAhead) {
self.lblDeliveryPrice.text = [NSString stringWithFormat:@"$%.2f", [self.orderAheadMenu.deliveryPrice floatValue]];
if ([self isSubscribedToOA]) {
self.lblDeliveryPrice.text = @"$0";
}
else {
self.lblDeliveryPrice.text = [NSString stringWithFormat:@"$%.2f", [self.orderAheadMenu.deliveryPrice floatValue]];
}
}

// if no promo added
Expand Down Expand Up @@ -838,6 +855,23 @@ - (void)updateUI
}

[self.btnGetItNow setTitle:strTitle forState:UIControlStateNormal];

// subscribed
if (self.orderMode == OrderAhead) {
if (self.orderAheadMenu.deliveryPrice != nil) {
NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"$%.2f", [self.orderAheadMenu.deliveryPrice floatValue]]];

[titleString addAttribute:NSStrikethroughStyleAttributeName
value:[NSNumber numberWithInteger:NSUnderlineStyleSingle]
range:NSMakeRange(0, [titleString length])];

self.lblDeliveryPricePrevious.attributedText = titleString;
}

if ([self isSubscribedToOA]) {
self.lblDeliveryPricePrevious.hidden = NO;
}
}
}

- (void)clearCart {
Expand Down Expand Up @@ -1788,7 +1822,14 @@ - (NSDictionary *)buildRequest:(NSString *)stripeToken
[detailInfo setObject:[NSString stringWithFormat:@"%.2f", [[BentoShop sharedInstance] getDeliveryPrice]] forKey:@"delivery_price"];
}
else if (self.orderMode == OrderAhead) {
[detailInfo setObject:[NSString stringWithFormat:@"%.2f", [self.orderAheadMenu.deliveryPrice floatValue]] forKey:@"delivery_price"];

if ([self isSubscribedToOA]) {
[detailInfo setObject:@"0" forKey:@"delivery_price"];
}
else {
[detailInfo setObject:[NSString stringWithFormat:@"%.2f", [self.orderAheadMenu.deliveryPrice floatValue]] forKey:@"delivery_price"];
}

}

[request setObject:detailInfo forKey:@"OrderDetails"];
Expand Down

0 comments on commit 76bfae5

Please sign in to comment.