Skip to content

Commit 37fadcd

Browse files
committed
remove the file if teh cart is empty
1 parent 1738221 commit 37fadcd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Moltin/Cart/Storage/LaravelFile.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ protected function saveCart()
204204
$data = static::$cart;
205205
$cartFilename = $this->storagePath . '/' . $this->identifier . '.json';
206206

207-
file_put_contents($cartFilename, json_encode($data));
207+
if (!empty($data)) {
208+
file_put_contents($cartFilename, json_encode($data));
209+
} else if (file_exists($cartFilename)) {
210+
unlink($cartFilename);
211+
}
208212
}
209213
}

0 commit comments

Comments
 (0)