Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Urgent: Need help extracting data with JCart shopping cart

Posted on 2011-02-21
4
Medium Priority
?
1,496 Views
Last Modified: 2013-12-13
I need some help big time with a shopping cart I've built with JCart.  I built the thing over the weekend and was feeling pretty good about it until I was told this morning that we need to collect tax on some of the items in the cart.  My company runs several summer camps for kids and the shopping cart allows the parents to purchase things for them to take to camp.  It also allows parent to put money on a gift card that the kid uses at camp to buy other things.  The things are taxable and the gift card is not.  And therein lies my problem - that and the fact that this has to be done inside of a week.

I really want to make the buying part as easy as possible but can't figure out how to separate the non-taxable item from the others.  I figured that I could subtract the amount of the non-taxable item from the total, figure the tax and add it back in, but I can't even figure out how to access the array the shopping cart is using to begin to start.

I'm attaching the array from a recent test of the cart.  In this instance, I'm looking for the item named 'Trading Post' with a value of 25. It looks like thel product name (trading post) is being assigned the value (25), but I don't understand how to work with this at this time.  Ultimately, this will all need to go into a database but first things first.

I'm sure this isn't as clear as it needs to be as I'm in an almighty hurry, but any help would be greatly appreciated.
object(Jcart)#1 (8) {
  ["config"]=>
  array(12) {
    ["jcartPath"]=>
    string(6) "jcart/"
    ["checkoutPath"]=>
    string(12) "checkout.php"
    ["item"]=>
    array(6) {
      ["id"]=>
      string(10) "my-item-id"
      ["name"]=>
      string(12) "my-item-name"
      ["price"]=>
      string(13) "my-item-price"
      ["qty"]=>
      string(11) "my-item-qty"
      ["url"]=>
      string(11) "my-item-url"
      ["add"]=>
      string(13) "my-add-button"
    }
    ["paypal"]=>
    array(5) {
      ["id"]=>
      string(13) "PGUFPYYKF54EY"
      ["https"]=>
      bool(true)
      ["sandbox"]=>
      bool(false)
      ["returnUrl"]=>
      string(0) ""
      ["notifyUrl"]=>
      string(0) ""
    }
    ["currencyCode"]=>
    string(3) "USD"
    ["csrfToken"]=>
    bool(false)
    ["text"]=>
    array(14) {
      ["cartTitle"]=>
      string(13) "Shopping Cart"
      ["singleItem"]=>
      string(4) "Item"
      ["multipleItems"]=>
      string(5) "Items"
      ["subtotal"]=>
      string(8) "Subtotal"
      ["update"]=>
      string(6) "update"
      ["checkout"]=>
      string(8) "checkout"
      ["checkoutPaypal"]=>
      string(20) "Checkout with PayPal"
      ["removeLink"]=>
      string(6) "remove"
      ["emptyButton"]=>
      string(5) "empty"
      ["emptyMessage"]=>
      string(19) "Your cart is empty!"
      ["itemAdded"]=>
      string(11) "Item added!"
      ["priceError"]=>
      string(21) "Invalid price format!"
      ["quantityError"]=>
      string(38) "Item quantities must be whole numbers!"
      ["checkoutError"]=>
      string(34) "Your order could not be processed!"
    }
    ["button"]=>
    array(4) {
      ["checkout"]=>
      string(0) ""
      ["paypal"]=>
      string(0) ""
      ["update"]=>
      string(0) ""
      ["empty"]=>
      string(0) ""
    }
    ["tooltip"]=>
    bool(true)
    ["decimalQtys"]=>
    bool(false)
    ["decimalPlaces"]=>
    int(1)
    ["priceFormat"]=>
    array(3) {
      ["decimals"]=>
      int(2)
      ["dec_point"]=>
      string(1) "."
      ["thousands_sep"]=>
      string(1) ","
    }
  }
  ["items:private"]=>
  array(4) {
    [0]=>
    string(1) "3"
    [1]=>
    string(3) "sb1"
    [2]=>
    string(3) "ah1"
    [3]=>
    string(11) "tradingPost"
  }
  ["names:private"]=>
  array(4) {
    [3]=>
    string(11) "T-Shirt (L)"
    ["sb1"]=>
    string(11) "Silly Bands"
    ["ah1"]=>
    string(15) "Autograph Horse"
    ["tradingPost"]=>
    string(12) "Trading Post"
  }
  ["prices:private"]=>
  array(4) {
    [3]=>
    string(2) "12"
    ["sb1"]=>
    string(1) "5"
    ["ah1"]=>
    string(2) "13"
    ["tradingPost"]=>
    string(4) "1.00"
  }
  ["qtys:private"]=>
  array(8) {
    [3]=>
    string(1) "1"
    ["sb1"]=>
    string(1) "1"
    ["ah1"]=>
    string(1) "1"
    [4]=>
    string(1) "4"
    [2]=>
    string(1) "4"
    [1]=>
    string(1) "4"
    ["ag1"]=>
    string(1) "1"
    ["tradingPost"]=>
    string(2) "25"
  }
  ["urls:private"]=>
  array(4) {
    [3]=>
    string(0) ""
    ["sb1"]=>
    string(0) ""
    ["ah1"]=>
    string(0) ""
    ["tradingPost"]=>
    string(0) ""
  }
  ["subtotal:private"]=>
  float(55)
  ["itemCount:private"]=>
  int(28)
}

Open in new window

0
Comment
Question by:saabStory
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 800 total points
ID: 34945203
Then let us understand some more.
So the "private" part of the array are the items that are add-ons for the camp, right ?
0
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1200 total points
ID: 34945797
0
 

Author Comment

by:saabStory
ID: 34947513
Roads_Roads, I believe the private refers to one of the classes being used on this application, though I'm not sure.

Ray_Paseur - I did see that and unfortunately, it won't totally help me.  Part of my shopping cart may or may not be a gift card that is not taxed. If I understand the PayPal tax rate correctly, it applies tax to everything.  I need to apply tax to everything but the gift card.

The only thing I'm coming up with on my own is to parse the querystring that is sent to PayPal before it's sent to PayPal.  Not the whole thing but I can build the piece that I need, explode it, remove the part that has the string 'Trading+Post', add the remaining amounts back together, tax that and tack that onto the querystring and then send it to PayPal.  The problem is that the non-taxable piece - the 'Trading Post' won't always appear in the same place - it's position in the array will depend on when the person added that particular product.

Cumbersome, but it's all I can come up with at the moment.

FYI, the paypal querystring is as follows:
?cmd=_cart&upload=1&charset=utf-8¤cy_code=USD&business=XXXXXXXXXXX&return=¬ify_url=&item_number_1=3&item_name_1=T-Shirt+%28L%29&amount_1=12&quantity_1=1&item_number_2=1&item_name_2=T-Shirt+%28S%29&amount_2=12&quantity_2=1&item_number_3=tradingPost&item_name_3=Trading+Post&amount_3=1.00&quantity_3=65

Open in new window

0
 

Author Closing Comment

by:saabStory
ID: 34985754
I appreciate all the comments and pointers. I was ultimately able to solve my issue by hacking the functions that drove the cart and dealing with that with plain php rather than trying to parse the querystring back and forth.  Something in another post on the Jcart forum popped into focus as I was looking at the cart code so it was good that I went back to re-read the posts.

Thanks to you both.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was initially published on Monitis Blog, you can read it here . When it comes to deciding which approach to website performance monitoring is best for your business, unfortunately, like so many options in life . . . it depends. In th…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question