Solved

Urgent: Need help extracting data with JCart shopping cart

Posted on 2011-02-21
4
1,454 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
  • 2
4 Comments
 
LVL 27

Assisted Solution

by:Lukasz Chmielewski
Lukasz Chmielewski earned 200 total points
Comment Utility
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 108

Accepted Solution

by:
Ray Paseur earned 300 total points
Comment Utility
0
 

Author Comment

by:saabStory
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Are you using email marketing software? If not, you're missing out on effortless marketing and the reaching of desired conversion rates through email marketing software.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now