Add #10 envelope printing option

This commit is contained in:
Skylar Ittner 2025-01-01 00:30:17 -07:00
parent 2c1406b916
commit d8feed270d
16 changed files with 569 additions and 5 deletions

View File

@ -3,7 +3,7 @@
<div class="copyright">
<a href="{{site_root}}refunds">Refund Policy and Instructions</a>
<br />
&copy; 2021-2023 <a href="https://postalportal.net">PostalPortal LLC</a>.<br>
&copy; 2021-2025 <a href="https://postalportal.net">PostalPortal LLC</a>.<br>
Developed and hosted by <a href="https://netsyms.com">Netsyms Technologies</a>.
<br />
<a href="https://postalportal.net/#contact">Contact Us</a>

View File

@ -181,7 +181,7 @@
<input id="postagetype_plain" type="radio" name="postageservice" value="plain" />
<label for="postagetype_plain"><b>No Extras</b>
<br />
Make an envelope with no special features or signature.
Make an envelope with no special features or signature, just regular postage.
</label>
</div>
</div>
@ -210,6 +210,13 @@
Use a USPS-provided red and white Flat Rate envelope for Priority Mail. You can pick one up at any post office.
</label>
</div>
<div class="col-4 col-12-small">
<input id="no10_envelope" type="checkbox" name="no10_envelope" value="no10_envelope" />
<label for="no10_envelope"><b>Print on an #10 Envelope</b>
<br />
If you want to print directly to a #10 envelope, select this option and we'll adjust the PDF accordingly.
</label>
</div>
</div>
<br />

View File

@ -5,4 +5,10 @@ the options you choose. Click the image to get a PDF for a test print.
<a href="{{site_root}}sample.pdf">
<img src="{{site_root}}sample.png" alt="Sample" style="border: 1px solid #aaa; box-shadow: 0 3px 10px rgb(0 0 0 / 0.2); max-width: 100%;"/>
</a>
Sample for printing on a #10 envelope:
<a href="{{site_root}}sample_no10.pdf">
<img src="{{site_root}}sample_no10.png" alt="#10 sample" style="border: 1px solid #aaa; box-shadow: 0 3px 10px rgb(0 0 0 / 0.2); max-width: 100%;"/>
</a>

View File

@ -113,7 +113,8 @@ function submitPayment() {
"rateid": rateid,
"stripeid": result.paymentMethod.id,
"price": price,
"label_only": document.getElementById('label_only').checked ? "1" : ""
"label_only": document.getElementById('label_only').checked ? "1" : "",
"no10_envelope": document.getElementById('no10_envelope').checked ? "1" : ""
},
dataType: "json",
timeout: 1000 * 30,

View File

@ -78,6 +78,9 @@ try {
}
if (!empty($_REQUEST["flat_rate"]) && $_REQUEST["flat_rate"] == "flat_rate") {
if (!empty($_REQUEST["no10_envelope"]) && $_REQUEST["no10_envelope"] == "no10_envelope") {
throw new Exception("You can't use your own envelope with Priority Mail Flat Rate. Use a USPS-provided Flat Rate envelope instead.");
}
$shipmentinfo["parcel"] = \EasyPost\Parcel::create([
"predefined_package" => "FlatRateEnvelope",
"weight" => $weight

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -57,7 +57,37 @@ try {
// load postage image
$labelimage = imagecreatefrompng($labelurl);
if ($shipment->postage_label->label_size == "4x6") {
$paperSize = "Letter";
$paperOrientation = "P";
if (!empty($_REQUEST["no10_envelope"]) && $_REQUEST["no10_envelope"] == "1") {
$paperSize = [9.5, 4.125];
$paperOrientation = "L";
if ($shipment->postage_label->label_size == "4x6") {
if (!empty($shipment->options->certified_mail)) {
// envelope with banner
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10_4x6_certified.png");
} else {
// plain envelope
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10.png");
}
$labelimage = imagerotate($labelimage, 270, 0);
imagecopyresampled($paperimage, $labelimage, 525, 19, 0, 0, 1200, 1800, 1200, 1800);
} else {
if (!empty($shipment->options->certified_mail)) {
// envelope with banner
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10_certified.png");
imagecopyresampled($paperimage, $labelimage, 375, 190, 0, 0, 2100, 900, 2100, 900);
if ($shipment->options->delivery_confirmation == "SIGNATURE_RESTRICTED") {
$restrictedstamp = imagecreatefrompng(__DIR__ . "/restricted_delivery.png");
imagecopyresampled($paperimage, $restrictedstamp, 450, 825, 0, 0, 600, 225, 600, 225);
}
} else {
// plain envelope
$paperimage = imagecreatefrompng(__DIR__ . "/papertemplate_no10.png");
imagecopyresampled($paperimage, $labelimage, 375, 90, 0, 0, 2100, 900, 2100, 900);
}
}
} else if ($shipment->postage_label->label_size == "4x6") {
if ((!empty($_REQUEST["label_only"]) && $_REQUEST["label_only"] == "1") || $shipment->parcel->predefined_package == "FlatRateEnvelope") {
if (!empty($shipment->options->certified_mail)) {
// label and banner only
@ -109,7 +139,7 @@ try {
imagepng($paperimage, $tmpfile);
// Generate PDF from image
$pdf = new FPDF('P', 'in', 'Letter');
$pdf = new FPDF($paperOrientation, 'in', $paperSize);
$pdf->AddPage();
$pdf->Image($tmpfile, 0, 0, -300, -300, "PNG");

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB