Forums / General Questions / Pre-processing of downloadable products.

Pre-processing of downloadable products.

Locked

Started by ogradyjd on 30 May 2009, 10:08 PM · Views: 612

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
30 May 2009, 10:08 PM
#1
ogradyjd avatar

ogradyjd

New Zenner

Join Date:
May 2009
Posts:
3
Plugin Contributions:
0

Pre-processing of downloadable products.

My installation info is at the bottom of this note.

The bad news is that I'm a complete n00b to Zen Cart. The good news is that I'm a developer of 15 years, so this is just a query for information, not a cry for someone to do everything for me.

The problem is this - my site just had Zen installed as our webstore, and we are going to be selling a lot of Acrobat pdfs. When someone buys a copy of a pdf file, we want checkout to kick off a process that will watermark the pdf with the name of the purchaser. Once that's done, checkout can then continue on with its normal downloadable content process.

I already figured out how to watermark the pdfs - with a command line tool called Coherent. Of course, if there's a better tool more integrated with PHP, mentioning that would be nice. What I'm looking to do with Coherent is to have PHP shell out and run a shell script which runs the watermark command on the outgoing pdf. The info I need is exactly how to go about instrumenting the checkout process so that it does this extra thing with downloadable content during the order processing.

If someone could tell me what the best way to do this in Zen would be, I'd greatly appreciate it. Even to point to a file that I should modify, or the page in the API docs where I should look - anything would help save me days of crawling the net.

Server OS: Linux 2.6.9-67.0.7.ELsmp
Database: MySQL 5.0.77-community
Server Date: 05/30/2009 16:41:56
Database Date: 05/30/2009 13:41:56
Server Up Time: 13:41:56 up 437 days, 5:42, 0 users, load average: 0.11, 0.09, 0.08
HTTP Server: Apache/2.0.63 (Unix) mod_ssl/2.0.63 OpenSSL/0.9.7a mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
PHP Version: 5.2.6 (Zend: 2.2.0)
PHP Memory Limit: 32M
PHP Safe Mode: Off
PHP File Uploads: On
Max Size: 40M
POST Max Size: 10M
Database Data Size: 225 kB
Database Index Size: 353 kB
Zen Cart 1.3.8a
Database Patch Level: 1.3.8
v1.3.8 [2009-05-25 19:03:46] (Fresh Installation)

31 May 2009, 4:26 PM
#2
drbyte avatar

drbyte

Sensei

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

Re: Pre-processing of downloadable products.

Assuming you're using the (safer) download-by-redirect mode that's enabled by default, I would suggest writing an observer class to hook the 'NOTIFY_DOWNLOAD_VIA_SYMLINK___BEGINS' notifier, and use that to intercept the file that's been prepared for download. Perhaps use the symlinked version of the file (maybe add a suffix to the symlink temporarily) as the source for the raw original, then process that to create the new file, wiping out the symlink and creating a new file of the same name in its place. Then the normal download activity will follow.

The logic for preparing and serving the downloads is found in /includes/modules/pages/download/header_php.php
Short of maybe passing a parameter (like the path/filename at hand) to the notifier hook, you shouldn't have to make any alterations to the code in that file when using the observer class to do the added work you need.

.
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.