Overview
Phyto Care Card bridges the gap between selling a plant and ensuring the buyer can actually keep it alive. Specialty plant retailers โ particularly those selling tissue-culture deflasks, rare aroids, or carnivorous plants that need specific growing conditions โ frequently get post-purchase support requests simply because customers did not have access to the right care information at the right time.
This plugin solves that directly. An admin fills in a structured set of care fields (light, watering, humidity, temperature, potting media, fertilisation, dormancy notes, and special tips) on the product edit screen. A formatted A4 PDF care guide is built on demand from those fields โ no external library, no composer dependency, no third-party service. Customers can download it straight from the product page, and it can be automatically attached to the WooCommerce order completion email so they receive it the moment their order ships.
Care Fields
Fill in the Plant Care Card meta box on any product edit page:
| Field Name | Meta Key | Type | Notes |
|---|---|---|---|
| Light Requirements | _phyto_cc_light_req | Select | Full Sun / Partial Shade / Bright Indirect / Low Light / Grow Light |
| Watering | _phyto_cc_watering | Text | Free text, e.g. “Water when top 2 cm dry” |
| Humidity | _phyto_cc_humidity | Text | e.g. “60โ80% RH” |
| Temperature Min (ยฐC) | _phyto_cc_temp_min | Number | Decimal allowed |
| Temperature Max (ยฐC) | _phyto_cc_temp_max | Number | Decimal allowed |
| Potting Media | _phyto_cc_potting_media | Text | e.g. “Chunky bark + perlite 60/40” |
| Fertilisation | _phyto_cc_fertilisation | Text | e.g. “Half-strength balanced NPK fortnightly” |
| Dormancy Notes | _phyto_cc_dormancy_notes | Textarea | Full dormancy description |
| Special Care Tips | _phyto_cc_special_tips | Textarea | Acclimation notes, common mistakes, extras |
| Attach to Order Email | _phyto_cc_attach_email | Checkbox | Attach PDF to customer_completed_order email |
The download button on the product page only appears when at least one care field is non-empty โ so products without care data are unaffected.
PDF Layout
The care guide is built as a raw PDF 1.4 document using PHP string concatenation. No external library or Composer dependency is required. Standard PDF fonts only: Helvetica and Helvetica-Bold.
Header bar โ Forest-green (#1a3c2b) rectangle spanning the full page width. “Plant Care Guide” is set in white Helvetica-Bold 18pt. The product name appears below in white Helvetica 13pt. “PhytoCommerce” branding sits in the top-right corner in sage (#7dab8a) at 8pt.
Two-column grid โ The six short fields are laid out in two columns of three rows each:
- Left column: Light, Water, Humidity
- Right column: Temperature, Potting Media, Fertilisation
Each pair shows the field label in Helvetica-Bold 9pt (forest green) followed by the value in Helvetica 9pt (black).
Full-width sections โ Dormancy Notes and Special Care Tips each appear below the two-column grid with a section heading in Helvetica-Bold. Long text is word-wrapped at 110 characters per line.
Footer โ “Generated by PhytoCommerce ยท phyto-evolution.github.io/PhytoCommerce” in 7pt grey Helvetica, separated by a light rule.
Download URL
https://yourstore.com/care-card/{product_id}/
The URL resolves via a custom WordPress rewrite rule registered at plugin activation. No server-level .htaccess editing is needed. The PDF is served with:
Content-Type: application/pdfContent-Disposition: inline; filename="care-guide-{product-slug}.pdf"
After activation, visit Settings โ Permalinks and click Save Changes to flush the rewrite rules.
Email Attachment
- Open the product edit screen in WP Admin.
- In the Plant Care Card meta box, tick Attach this care card PDF to the customer completed-order email.
- Save the product.
When a customer’s order status changes to Complete, the plugin iterates over every order item. For each product that has the email-attachment flag enabled and at least one care field populated, the PDF is generated and written to:
{wp-uploads}/phyto-care-cards/product-{id}.pdf
The file path is appended to WooCommerce’s email attachment array. Duplicate product IDs within the same order are deduplicated automatically.
Hooks
phyto_cc_fields_output
Filter the rendered care-fields HTML block before it is output on the product page. Return an empty string to suppress the block for specific products or contexts.
/**
* @param string $output Rendered HTML for the care-field section.
* @param int $product_id WooCommerce product ID.
*/
add_filter( 'phyto_cc_fields_output', function( $output, $product_id ) {
// Example: suppress for a specific product.
if ( 99 === $product_id ) {
return '';
}
return $output;
}, 10, 2 );
phyto_cc_attach_email
Filter the array of file paths appended to the order completion email after the plugin has added its PDFs.
/**
* @param array $attachments File paths appended by the plugin.
* @param WC_Order $order The completed order.
*/
add_filter( 'phyto_cc_attach_email', function( $attachments, $order ) {
// Example: skip attachment for wholesale orders.
if ( $order->get_meta( '_is_wholesale' ) ) {
return array();
}
return $attachments;
}, 10, 2 );
Source Layout
phyto-care-card/
โโโ phyto-care-card.php # Bootstrap, constants, rewrite rule, WC check, activation hooks
โโโ includes/
โ โโโ class-phyto-care-card-admin.php # Product meta box โ care fields + save/sanitise
โ โโโ class-phyto-care-card-frontend.php # Download button + PDF serve endpoint
โ โโโ class-phyto-care-card-generator.php # Raw PDF 1.4 builder โ no external library
โ โโโ class-phyto-care-card-email.php # Attach PDF to customer_completed_order email
โโโ assets/css/frontend.css # Download button styles
โโโ README.md
PrestaShop Equivalent
The PrestaShop version of this module is phyto_care_card in the modules/ directory. The meta key naming convention (_phyto_cc_*) is designed to mirror the PrestaShop field structure to simplify any future cross-platform data migration.