Zen Cart Logo
Forums / General Questions / extra_cart_actions - product variables needed

extra_cart_actions - product variables needed

Views: 896

Results 1 to 14 of 14
11 Oct 2012, 9:17 AM
#1
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

extra_cart_actions - product variables needed

Hi

Can anyone help with this please?

I am writing an extra_cart_actions .php file which needs the option values from each of two drop-downs from a product. My use of PHP is not extensive but I have modified quite a bit of PHP over last 2 years in different contexts.

What I am struggling with is getting the variables from the product when add to cart is clicked. I would ideally like to know the product id, catergory id, option id and selected option value.

Any help will be greatly appreciated.

Thanks
Vern

11 Oct 2012, 4:08 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: extra_cart_actions - product variables needed

What are your "extra actions" going to do with the data?

11 Oct 2012, 7:52 PM
#3
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

Hi

I'm going to use that info to create a custom pdf file for download.

Thanks
Vern

11 Oct 2012, 7:54 PM
#4
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

However, I am now looking at Observer Classes as a solution using NOTIFIER_CART_ADD_CART_END.

Any thoughts?

11 Oct 2012, 7:59 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: extra_cart_actions - product variables needed

Why are you creating the custom PDF before they even purchase it?

11 Oct 2012, 8:28 PM
#6
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

It seems to be the simplest point at which to do so. I could do it when payment complete I suppose NOTIFY_HEADER_END_CHECKOUT_SUCCESS but still i would need to identify the category, product and option values and I don;t know how to do that.
Thanks

12 Oct 2012, 7:53 AM
#8
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

Hi There

Watermarking/stamping looks good! Thanks.
I really am at the beginning of a steep learning curve.
My main problem seems to be knowing what variables I can access and understanding how to retrieve them.

This is what i want to achieve:

A product with 2 dropdowns (That is straight forward!)
A pdf is created using text and image resources based on the selected option 1 value and option 2 value. I am using fpdf for creating the pdf file - that works fine!
The pdf is saved to the download folder. It may not be necessary for the pdf to be watermarked or stamped but I could look at that later.

I have so far created an observer class which is triggered by NOTIFIER_CART_ADD_CART_END which creates a pdf and saves it in the download folder.

What it doesn't do is create the pdf based on the option values from the dropdowns as I don't know how to access those values. What variables are used to store them? I think this is probably a very basic question but as my experience of working with PHP in Zen Cart is virtually zero, I need all the help I can get.

Many many thanks
Vern

12 Oct 2012, 8:09 AM
#9
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

Hi Dr Byte

A thought ... can you recommend a Zen Cart book that would teach me how to work with the system?

Thanks again
Vern

12 Oct 2012, 8:36 AM
#10
gilby avatar

gilby

Totally Zenned

Join Date:
Aug 2005
Location:
Vic, Oz
Posts:
1,816
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

vernb:

Hi Dr Byte

A thought ... can you recommend a Zen Cart book that would teach me how to work with the system?

Thanks again
Vern
Scroll down to the bottom of the page!

12 Oct 2012, 8:47 AM
#11
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

Thanks but having looked at the Table of Content 99% of the book is not what I am looking for and the other 1% might be but it isn't clear! I already have have designed and set up a zen cart store which is customised to look like the website it is related to. It sells downloads and works fine. What I am looking for is a reference book which will guide me through customising the coding side listing classes, functions, notifiers, variables and how to use them!
Any further thoughts would be appreciated.

12 Oct 2012, 11:59 AM
#12
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,089
Plugin Contributions:
56

Re: extra_cart_actions - product variables needed

For determining what variables are available on a particular page and debugging, my go-to plugin is Super Globals Plus

13 Oct 2012, 6:28 PM
#13
vernb avatar

vernb

New Zenner

Join Date:
Jul 2010
Posts:
10
Plugin Contributions:
0

Re: extra_cart_actions - product variables needed

Hi

I am quite new to the PHP side of Zen Cart but have quite a bit of experience with Javascript and other programming languages and I have modified PHP files here and there in different contexts. My current knowledge and "expertise" is not up to problem that I am trying to solve... that of creating pdf products based on selections made by the buyer.

I am writing an Observer Class and so far so good. It works and is triggered by the relevant NOTIFY. What I don't know how to do is grab the cart data in the form of variables that I can use e.g. which products are in the cart, their quantities, attribute values, categories. If I can have them in the form of straightforward varaibles e.g. string, array, integer etc. then I can work with them to achieve my desired goal, that of creating a custom pdf based on choices made from dropdowns.

This must seem a very basic question to many of you very experienced programmers but if anyone can help I would really appreciate it.

Thanks
Vern

15 Oct 2012, 12:00 AM
#14
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: extra_cart_actions - product variables needed

$_SESSION['cart'] contains the cart contents before checkout begins