Skip to content

Commit

Permalink
Hotfix: Batch label creation merges wrong shipping labels
Browse files Browse the repository at this point in the history
Within a bulk action each labels will be downloaded
and merged into one big PDF.
Some orders already have labels created manually (via edit screen),
so unfortunately a merge contains such "old" labels too.
Therefor the caching of already created labels needs a proper hash
to separate new and old ones even across API versions.

- Hash of URL covers more scenarios than the described one.
- Pay attention that this can lead to much obsolete files over time.
- see github #125 for more
  • Loading branch information
Mike Pretzlaw committed Aug 2, 2017
1 parent 72d5a08 commit a18621a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion components/woo/order-bulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function create_label( $request ) {
*/
protected function save_label( $order_id, $url ) {
$path = $this->get_storage_path( 'order' . DIRECTORY_SEPARATOR . $order_id )
. DIRECTORY_SEPARATOR . 'label.pdf';
. DIRECTORY_SEPARATOR . md5( $url ) . '.pdf';

if ( file_exists( $path ) ) {
// Might be already downloaded, so we won't overwrite it.
Expand Down

0 comments on commit a18621a

Please sign in to comment.