Tips and Tricks HQ Support Portal › Forums › WP PDF Stamper › PDF Stamper – "dynamic" stamp on different pdfs
- This topic has 10 replies, 2 voices, and was last updated 6 years, 3 months ago by admin.
-
AuthorPosts
-
July 23, 2018 at 6:49 pm #14981support2Spectator
Saw this link: https://www.tipsandtricks-hq.com/wp-pdf-stamper/pdf-stamper-dynamically-modifying-the-text-to-stamp-data but not sure how to implement into our current code.
Does anyone have any sample for the above? Basically what we are trying to achieve is to stamp different text(not only different values) to different pdfs. For example, for certain pdfs, like type A we want to stamp this text: “Thank you [username]. This pdf is type A”. For pdfs, like type B we want to stamp this text: “Congratulations [username]. You won this pdf type B!”.
Is this possible?
July 24, 2018 at 9:40 am #78223adminKeymasterThis will need some customization. Are you going to be doing it on a per product basis? So different products will have different stamp? If you are, is WP eStore plugin being used for the products?
July 24, 2018 at 5:25 pm #78224support2SpectatorYes, we want to use it ‘per product’ basis so different products have different stamp depending on the pdf.
We actually are using the plugin using the “integration code” and not the WP eStore:
/*** Mandatory data ***/
// Post URL
$postURL = “https://www.yourwebsite.com/wp-content/plugins/wp-pdf-stamper/api/stamp_api.php”;
// The Secret key
$secretKey = “1234567890.11144468”;
//The source file URL (The file that you want to stamp)
$fileURL = “http://www.example.com/wp-content/uploads/test-ebook.pdf”;
/*** Optional Data ***/
//Customers Name
$customerName = “John Doe”;
//Customer Email address
$customerEmail = “john.doe@gmail.com”;
//Customer’s Address
$customerAddress = “123 Some Street, San Jose, CA – 95130, U.S.A.”;
// prepare the data
$data = array ();
$data = $secretKey;
$data = $fileURL;
$data = $customerName;
$data = $customerEmail;
$data = $customerAddress;
// send data to post URL
$ch = curl_init ($postURL);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
$returnValue = curl_exec ($ch);
// Process the return values
list ($status, $value) = explode (“n”, $returnValue);
if(strpos($status,”Success!”) !== false)
{
$file_url = trim($value);
echo “The URL of the stamped file is: “.$file_url;
}
else
{
echo “An error occured while trying to stamp the file! Error details: “.$value;
}
Is it possible to do what we want using the integration code?
Let me know if you want to see our full code as the above is just the sample from the plugin but basically our code is based off of it.
July 25, 2018 at 7:46 am #78225adminKeymasterYeah. Basiclaly, you are executing the API query to stamp a file from your custom code. Your code in charge of what gets stamped. The $data variable is where you specify which file to be stamped.
I don’t know the full scope of your custom code but you will need to add condition there so you send different PDF file based on whatever criteria you have.
Are you a PHP coder though? This type of customization really requires good coding knowledge. This is not going to be just a couple of lines of code changes type of customization.
July 25, 2018 at 7:08 pm #78226support2SpectatorThe $data variable – i understand that, yes you need a condition and based on that condition the variable will be set.
What im looking for assistance here is to tell me how/what code to use to ‘manipulate’ the text to stamp code. (As this code is somewhat ‘hardcoded’ into the plugin – from the Settings menue of the plugin in wordpress)
I can create the conditions, etc. in php no problem, but like i said, i need to know what code it is to use and in what file, etc.
July 26, 2018 at 3:15 am #78227adminKeymasterokay, the following filter is what you used to customize the stamping text
filter_stamper_text_after_replacing_tags
This filter passes two parameters. The 2nd parameter is an array that contains the product name. You can read it like the following:
$product_name = $additional_params;
Then use it to add your condition and change the stamping text value.
Now, normally when you use WP eStore’s standard integration, we pass the product name value to the API so it will be available in the above mentioned filter. In your case, you are doing a custom integration. So from your customer code, you will need to pass the product name using the “product_name” parameter. Below is an example of what you add to the $data array before making the cURL request:
$data = array ();
$data = $secretKey;
$data = $fileURL;
$data = $customerName;
$data = $customerEmail;
$data = $customerAddress;
$data = $productName;
July 31, 2018 at 11:24 pm #78228support2SpectatorI set this code for testing:
$data = array ();
$data = $secretKey;
$data = $fileURL;
$customerName = “John Smith”;
$data = $customerName;
$customerBusinessName = “PizzaRUs”;
$data = $customerBusinessName;
$data = $customerEmail;
$data = $customerAddress;
$productName = “Hello world stamper”;
$data = $productName;
but it is not stamping anything, only the default parameters.
Also, within the plugin settings(wp->PDF Stamper->Settings) in the “Stamp Text Layout Settings” section I added this to the “Text to Stamp” field box: “{customer_business_name} : {customer_name} {product_name}”. The pdf gets stamped but it stamps this: “PizzaRUs : John Smith {product_name}”, so it does not recognize the ‘product_name’ parameter as a parameter so it stamps it as text.
August 2, 2018 at 5:10 pm #78229support2Spectatorhelp anyone?
August 2, 2018 at 11:38 pm #78230adminKeymasterDid you also add code that uses that parameter in the following filter?
Can you show me the code for what you have done with that filter?
August 3, 2018 at 10:41 pm #78231support2SpectatorI have not done anything with any filter(even with our working integrated custom code). From my original question, Im not sure what files/code needs to be edited to ‘add’ or edit any filter.
Due to the lack of options/functionality of the forum, we cant attach images. Looking at the directories of the plugin using ftp, I am listing some of the files that I think need to be edited:
In the wp-content/plugins/wp-pdf-stamper/api folder:
-clickbank-config.php
-dc.php
-ipn_customization_config.php
-ipn_handler.php
-stamp-api-include-3.php
-stamp_api.php
-stamp_api_function.php
-stamp_api_internal.php
-stamper_class_includes.php
What files need to be edited and where/how to add the code from the link?
August 4, 2018 at 11:42 pm #78232adminKeymasterThat needs to go in your custom code. Normally, a good idea is to create a small plugin and then put your custom code in there. I will need to send you an email for it.
-
AuthorPosts
- You must be logged in to reply to this topic.