Selaa lähdekoodia

Add download link for uploaded photo in order admin — v1.1.6 -> v1.1.7

- Hook woocommerce_after_order_itemmeta to show "Download uploaded
  photo" button with original filename below order item meta
- Only shown for items with _studiou_fpp_attachment_id meta
- Links directly to the raw uploaded file
- Add Czech translation: "Stáhnout nahranou fotografii"
- Update documentation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Dalibor Votruba 3 kuukautta sitten
vanhempi
commit
38b79760e0

+ 1 - 1
studiou-wc-free-photo-product/CLAUDE.md

@@ -2,7 +2,7 @@
 
 ## Project Overview
 
-WordPress/WooCommerce plugin called **studiou-wc-free-photo-product** (QDR - Studiou WC Free Photo Product) v1.1.6.
+WordPress/WooCommerce plugin called **studiou-wc-free-photo-product** (QDR - Studiou WC Free Photo Product) v1.1.7.
 Allows publishing special variable products where customers upload custom raw images to be printed for a price.
 
 ## Initial Requirements

+ 26 - 0
studiou-wc-free-photo-product/includes/class-studiou-wc-fpp-cart.php

@@ -37,6 +37,9 @@ class Studiou_WC_FPP_Cart {
 
         // Replace order item thumbnail with uploaded image (admin)
         add_filter('woocommerce_admin_order_item_thumbnail', array($this, 'admin_order_item_thumbnail'), 10, 3);
+
+        // Add download link to order item in admin
+        add_action('woocommerce_after_order_itemmeta', array($this, 'admin_order_item_download_link'), 10, 3);
     }
 
     public function add_cart_item_data($cart_item_data, $product_id, $variation_id) {
@@ -243,4 +246,27 @@ class Studiou_WC_FPP_Cart {
         }
         return $thumbnail;
     }
+
+    public function admin_order_item_download_link($item_id, $item, $product) {
+        $attachment_id = $item->get_meta('_studiou_fpp_attachment_id');
+        if (!$attachment_id) {
+            return;
+        }
+
+        $file_url = wp_get_attachment_url($attachment_id);
+        $file_name = $item->get_meta('_studiou_fpp_file_name');
+        if (!$file_url) {
+            return;
+        }
+
+        echo '<p class="studiou-fpp-order-download">';
+        echo '<a href="' . esc_url($file_url) . '" download class="button button-small">';
+        echo '<span class="dashicons dashicons-download" style="line-height:1.4;vertical-align:middle;"></span> ';
+        echo esc_html__('Download uploaded photo', 'studiou-wc-free-photo-product');
+        echo '</a>';
+        if ($file_name) {
+            echo ' <small>(' . esc_html($file_name) . ')</small>';
+        }
+        echo '</p>';
+    }
 }

+ 4 - 1
studiou-wc-free-photo-product/languages/studiou-wc-free-photo-product-cs_CZ.po

@@ -3,7 +3,7 @@
 # This file is distributed under the GPL v2 or later.
 msgid ""
 msgstr ""
-"Project-Id-Version: QDR - Studiou WC Free Photo Product 1.1.6\n"
+"Project-Id-Version: QDR - Studiou WC Free Photo Product 1.1.7\n"
 "Report-Msgid-Bugs-To: https://www.quadarax.com\n"
 "POT-Creation-Date: 2026-04-02 00:00+0000\n"
 "PO-Revision-Date: 2026-04-02 00:00+0000\n"
@@ -202,6 +202,9 @@ msgstr "Tento produkt musí být variabilní produkt."
 msgid "Please upload a photo before adding to cart."
 msgstr "Před přidáním do košíku prosím nahrajte fotografii."
 
+msgid "Download uploaded photo"
+msgstr "Stáhnout nahranou fotografii"
+
 msgid "Invalid file data."
 msgstr "Neplatná data souboru."
 

+ 5 - 1
studiou-wc-free-photo-product/languages/studiou-wc-free-photo-product.pot

@@ -2,7 +2,7 @@
 # This file is distributed under the GPL v2 or later.
 msgid ""
 msgstr ""
-"Project-Id-Version: QDR - Studiou WC Free Photo Product 1.1.6\n"
+"Project-Id-Version: QDR - Studiou WC Free Photo Product 1.1.7\n"
 "Report-Msgid-Bugs-To: https://www.quadarax.com\n"
 "POT-Creation-Date: 2026-04-02 00:00+0000\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
@@ -262,6 +262,10 @@ msgstr ""
 msgid "Please upload a photo before adding to cart."
 msgstr ""
 
+#: includes/class-studiou-wc-fpp-cart.php
+msgid "Download uploaded photo"
+msgstr ""
+
 #: includes/class-studiou-wc-fpp-single-product.php
 msgid "Invalid file data."
 msgstr ""

+ 2 - 0
studiou-wc-free-photo-product/readme.md

@@ -100,6 +100,7 @@ When a customer adds a photo product to the cart:
 - On checkout, the file record is linked to the order and order item
 - In the order admin, order item thumbnails show the uploaded photo instead of the product image
 - The uploaded photo file name appears as order item metadata
+- A **Download uploaded photo** button with the original file name is shown below the order item meta in admin
 - Files linked to orders cannot be removed by the customer
 
 ## Media Categories
@@ -218,6 +219,7 @@ studiou-wc-free-photo-product/
 | `woocommerce_store_api_checkout_order_processed` | Action | Links file record to order (block checkout) |
 | `woocommerce_thankyou` | Action | Fallback linking on thank-you page |
 | `woocommerce_admin_order_item_thumbnail` | Filter | Replaces order item thumbnail with uploaded photo |
+| `woocommerce_after_order_itemmeta` | Action | Shows download link for uploaded photo in order admin |
 | `woocommerce_product_data_tabs` | Filter | Adds Free Photo product tab |
 | `woocommerce_product_data_panels` | Action | Renders Free Photo settings panel |
 | `woocommerce_process_product_meta` | Action | Saves Free Photo product meta |

+ 2 - 2
studiou-wc-free-photo-product/studiou-wc-free-photo-product.php

@@ -3,7 +3,7 @@
  * Plugin Name: QDR - Studiou WC Free Photo Product
  * Plugin URI: https://www.quadarax.com/plugins/studiou-wc-free-photo-product
  * Description: Allows publishing special WooCommerce products with variants and custom raw image upload for photo printing
- * Version: 1.1.6
+ * Version: 1.1.7
  * Requires at least: 6.9.4
  * Requires PHP: 8.2
  * Author: Dalibor Votruba
@@ -21,7 +21,7 @@ if (!defined('WPINC')) {
     die;
 }
 
-if (!defined('STUDIOU_WCFPP_VERSION')) define('STUDIOU_WCFPP_VERSION', '1.1.6');
+if (!defined('STUDIOU_WCFPP_VERSION')) define('STUDIOU_WCFPP_VERSION', '1.1.7');
 if (!defined('STUDIOU_WCFPP_PLUGIN_DIR')) define('STUDIOU_WCFPP_PLUGIN_DIR', plugin_dir_path(__FILE__));
 if (!defined('STUDIOU_WCFPP_PLUGIN_URL')) define('STUDIOU_WCFPP_PLUGIN_URL', plugin_dir_url(__FILE__));
 if (!defined('STUDIOU_WCFPP_PLUGIN_BASENAME')) define('STUDIOU_WCFPP_PLUGIN_BASENAME', plugin_basename(__FILE__));