Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / Pull customers_email_address into Products Description 2

Pull customers_email_address into Products Description 2

Started by abcschooldr on 19 Apr 2013, 7:20 PM · Views: 642

Results 1 to 4 of 4
19 Apr 2013, 7:20 PM
#1
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Post #1 by abcschooldr

v1.3.9h

My site uses both a Products Description 1 and a Products Description 2. Products Description 1 is the catalog description, and Products Description 2 shows in both checkout_success and email_template_checkout.html.

I sell courses. Products Description 2 includes a course link, user name and password information. In the past the user name and password was generic for everyone enrolled in the specific course. On the updated products....the user name will be the customers' email address and the password will be the customers' last name. I would like the user name to 'fill in' the correct email address and the password to 'fill in' the correct last name....rather than just telling the customer to use his/her email address and last name for these items.

Course Link
User Name: customers_email_address
Password: customers_lastname

I am changing the products one at a time so I don't want to just change the email_template_checkout.html. Not every one of my products will use this information yet.

Is it possible to write html for the Products Description 2 field that will pull this customer's information from the database so the customer's success information (page and email) fills in 'his' customer information from his order?

19 Apr 2013, 7:46 PM
#2
drbyte avatar

drbyte

Sensei

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

Post #2 by drbyte

The smarter way to do it would be to intercept the order-creation code and insert the customer's email address as an attribute describing that particular line-item. The process is the same as one would do to insert a PIN code or a software serial number generated uniquely at the time an order is placed.

I've posted numerous examples of this sort of thing in many forum posts.

Here are some of the "concept" details described right in the code of the order.php class:```
$this->notify('NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS', $custom_insertable_text);

/* START: ADD MY CUSTOM DETAILS

    1. calculate/prepare custom information to be added to this product entry in order-confirmation, perhaps as a function call to custom code to build a serial number etc:
  • Possible parameters to pass to custom functions at this point:
  • Product ID ordered (for this line item): $this->products[$i]['id']
    
  • Quantity ordered (of this line-item): $this->products[$i]['qty']
    
  • Order number: $zf_insert_id
    
  • Attribute Option Name ID: (int)$this->products[$i]['attributes'][$j]['option_id']
    
  • Attribute Option Value ID: (int)$this->products[$i]['attributes'][$j]['value_id']
    
  • Attribute Filename: $attributes_values->fields['products_attributes_filename']
    
    1. Add that data to the $this->products_ordered_attributes variable, using this sort of format:
  •  $this->products_ordered_attributes .=  {INSERT CUSTOM INFORMATION HERE};
    

*/

$this->products_ordered_attributes .= $custom_insertable_text;

/* END: ADD MY CUSTOM DETAILS */

The proper way is to hook the NOTIFY_ORDER_DURING_CREATE_ADD_PRODUCTS notifier point with an observer class and have that class insert the appropriate info whenever a relevant product is being moved from the shopping-cart into the paid order.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

19 Apr 2013, 8:17 PM
#3
abcschooldr avatar

abcschooldr

New Zenner

Join Date:
Feb 2012
Posts:
77
Plugin Contributions:
0

Post #3 by abcschooldr

Will this allow me the flexibility to include the customer's email/last name for the user name/password in the email/success page for some products, but not include this information and instead only post the product's description 2 information for the rest?
Can this be included only on some product orders...not all?...specific to the product itself?

19 Apr 2013, 8:31 PM
#4
drbyte avatar

drbyte

Sensei

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

Post #4 by drbyte

That section of code is run separately for every line-item on your order, so is specific to each product. It thus allows you to take specific action unique to whichever product it is processing at that time.

Have you ever sold a product with attributes? Using this approach simply lets you add extra attribute-description details to each individual product on your order, just like any existing attribute information would show up.
If your preference is to stuff an email address in there, that's fine. If you also want to add some other custom fields, that's fine. Exactly what you use is up to you.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.