View Cart|Wish List|Login|Register | Sunday, August 01, 2010
 
 Search   ..:: Support &
    Service
  Forum
::..
 
    Minimize
www.catalooksupport.com ::: another place for CATALooK.netStore support

    Minimize
SearchForum Home
     
  DotNetNuke  CATALooK.netStore  Percentage of O...
 Re: Percentage of Order Coupon
 
 5/9/2007 5:40:20 PM
webTester
39 posts


Re: Percentage of Order Coupon
Hi Steven,

Catalook is a very powerful system for the price.  We're using it to replace our present e-commerce system.  With all of it's features though there are some things our present system does that catalook doesn't have available.  So because of that I'm having to do some source code modifications and additions.

I'm guessing that, that will likely be your option here until catalook's next upgrade.  If you have the source it'd probably be better to make the needed changes there rather than scrap the project altogether ... I don't think that you'll find an e-comm solution for DNN that's as robust as this one.  I've looked.

With that said let me tell you what I'm doing to make my life easier when the next upgrade comes along. 

- I've had to make a few stored procedure changes to the catalook core but I'm keeping a log of all of the places where I'm making changes and I'm also adding my name in the comments of the modified stored procedures so that the changed portions will be easy to pinpoint later

- I'm also keeping a log of all of my code changes and adding comments with my name as well.  So if I ever need to look over what I've done I can just search for my name.

- I'm trying as much as possible to not change the catalook core because I'll have to reapply all those changes after the next upgrade but in some cases it's necessary to accomplish what I need to do.  So whenever possible, instead of changing tables or stored procs I've been creating new ones and integrating them into the system.  This has been working out well thus far ...

- I've found that most of my code changes have been centered in the shoppingcart.ascx.vb, shoppingcartDB.vb, and productsDB.vb ... this may vary for you depending upon what you're trying to do.

I hope that this proves helpful ... it will likely be a lot of work but I think that the payoff will make it worth it.

 5/10/2007 12:50:10 AM
Airstream345
50 posts


Re: Percentage of Order Coupon

webTester,
Thank you for your response.  I agree.  Thanks for the tips on code to review.  I'll start there.


Steven Webster
Overlook Technology
www.overlooktechnology.com
DNN Platinum Benefactor
 5/10/2007 4:39:59 AM
Airstream345
50 posts


Re: Percentage of Order Coupon

I've been looking through the code and have come up with the following concept.  Please review and let me know if this seems reasonable:

Modify code on CatlooKnetStore.Library/CodeBehind/ShoppingCart.apx.vb as follows:

  1. Modify CheckoutBtn_Click Event to pass an additional parameter for CartGoodsPrice to GetCouponAmount function as follows:

Private Sub CheckoutBtn_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles CheckoutBtn.Click

If Page.IsValid = True Then

Dim cart As ShoppingCartDB = New ShoppingCartDB

' Calculate shopping cart ID

Dim cartId As String = cart.GetShoppingCartId()

If tbCoupon.Text <> "" AndAlso CType(Settings("CATCart_CouponCodes"), String) <> "" AndAlso Not IsNothing(Settings("CATCart_CouponProductID")) AndAlso CType(Settings("CATCart_CouponProductID"), String) <> "" Then

REM - BEGIN modified for percentage coupon discounts - STW - 5.9.07

'original code

'Dim CouponAmount As Double = GetCouponAmount(tbCoupon.Text) * -1

'new code

Dim objCartPrice As New CartPriceInfo

Dim objCartPrices As New CartPriceController

objCartPrice = objCartPrices.GetCartPrice(UserId, GetShipToID, PortalId)

Dim CouponAmount As Double = GetCouponAmount(tbCoupon.Text, objCartPrice.CartGoodsPrice) * -1

REM - END modified for percentage coupon discounts - STW - 5.9.07

  1. Modify GetCouponAmount function to handle the existance of a percentage symbol and calc the discount based on the percentage x order total

Public Function GetCouponAmount(ByVal CouponCode As String, Optional ByVal OrderSubTotal As Double = 0.0) As Double

Dim arrCoupons() As String
Dim CouponAmount As Double = 0
Dim CouponCodes As String = CType(Settings("CATCart_CouponCodes"), String)

CouponCodes = CouponCodes.Replace(ControlChars.CrLf, ";")

Dim delimiter As String = "=;"

arrCoupons = CouponCodes.Split(delimiter.ToCharArray)

If Array.IndexOf(arrCoupons, CouponCode) <> -1 Then

Dim Amount As String = Convert.ToString(arrCoupons.GetValue(Array.IndexOf(arrCoupons, CouponCode) + 1))

If IsNumeric(Amount) Then

CouponAmount = Convert.ToDouble(Amount)

If RemoveUsedCoupons Then

Dim RemoveString As String = CouponCode & "=" & Amount

Dim newCouponCodes As String = CType(Settings("CATCart_CouponCodes"), String)

Dim StartIndex As Integer = newCouponCodes.IndexOf(RemoveString)

Dim CharsCount As Integer = RemoveString.Length

If StartIndex + CharsCount + 2 > newCouponCodes.Length Then

newCouponCodes = newCouponCodes.Remove(StartIndex, CharsCount)

Else

newCouponCodes = newCouponCodes.Remove(StartIndex, CharsCount + 2) 'incl. crlf

End If

Dim objModuleController As New ModuleController

objModuleController.UpdateModuleSetting(ModuleId, "CATCart_CouponCodes", newCouponCodes)

End If

REM - begin percentage discount coupons modification - STW - 5.9.07

Else 'coupon contains a non numeric character

If InStr(Amount, "%", CompareMethod.Binary) = 1 Then

CouponAmount = (Convert.ToDouble(Amount) / 100) * OrderSubTotal

End If

REM - end percentage discount coupons modification - STW - 5.9.07

End If

End If

Return CouponAmount

End Function

Does this look like I'm on the right path?

 


Steven Webster
Overlook Technology
www.overlooktechnology.com
DNN Platinum Benefactor
 5/10/2007 4:49:42 AM
Airstream345
50 posts


Re: Percentage of Order Coupon

Just realized I forgot to strip the '%' from the amount value

REM - begin percentage discount coupons modification - STW - 5.9.07

Else 'coupon contains a non numeric character

If InStr(Amount, "%", CompareMethod.Binary) = 1 Then

Amount = Replace(Amount.ToString, "%", "")

CouponAmount = (Convert.ToDouble(Amount) / 100) * OrderSubTotal

End If

REM - end percentage discount coupons modification - STW - 5.9.07


Steven Webster
Overlook Technology
www.overlooktechnology.com
DNN Platinum Benefactor
 5/10/2007 9:16:44 AM
host
1815 posts
1st


Re: Percentage of Order Coupon

Great work! There is only a problem if someone deletes something from his cart or changes the quantity of items. In this case the coupon discount amount should be updated. We will add this to the coming versions.

 5/10/2007 12:43:04 PM
Airstream345
50 posts


Re: Percentage of Order Coupon

So I'm in the right place and on the right path?  I'll check out adding some more coupon handling to the cart update event.

Glad to hear you'll be adding this to the next release. 


Steven Webster
Overlook Technology
www.overlooktechnology.com
DNN Platinum Benefactor
  DotNetNuke  CATALooK.netStore  Percentage of O...

    Minimize
www.excommerce.com ::: eXcommerce are a dedicated reseller of Catalook. If you want the features of catalook without the hassle of setup and maintenance and want some extra support options please check our services.
      

References / Live Stores | Forum | Trial Downloads | Resource Directory | Release History | Support Requests | Referral Program | Contact
CATALooK |  Terms Of Use |  Privacy Statement
Copyright 2002-2005 CATALooK