duncanmcclean / simple-commerce

A simple, yet powerful e-commerce addon for Statamic.
https://statamic.com/addons/duncanmcclean/simple-commerce
Other
147 stars 42 forks source link

Product variant assets not passed in REST API. #1178

Closed maarten-mald-digital closed 1 week ago

maarten-mald-digital commented 1 week ago

Description

In my blueprints > product > (field) product_variants i have 2 image fields

Thumbnail as "image" Images as "images"

Screenshot 2024-11-19 at 10 30 31

In the /cp uploading and showing this images works fine

Screenshot 2024-11-19 at 10 33 48

When fetching through the API a single "image" always work but "images" is always empty.

...
"product_variants": {
            "variants": [
                {
                    "name": "Deur/raam contact",
                    "values": [
                        "default",
                        "example"
                    ]
                }
            ],
            "options": [
                {
                    "key": "default",
                    "variant": "default",
                    "price": "€34.95",
                    "download_limit": null,
                    "downloadable_asset": {},
                    "price_from": null,
                    "rent_price": "€2.99",
                    "rent_price_from": "€3.99",
                    "image": {
                        "id": "aws::accessoires/deur-raamcontact.png",
                        "title": "deur-raamcontact.png",
                        "path": "accessoires/deur-raamcontact.png",
                        "filename": "deur-raamcontact",
                        "basename": "deur-raamcontact.png",
                        "extension": "png",
                        "is_asset": true,
                        "is_audio": false,
                        "is_previewable": false,
                        "is_image": true,
                        "is_svg": false,
                        "is_video": false,
                        "blueprint": {
                            "title": "Aws",
                            "handle": "aws"
                        },
                        "edit_url": "http://hyper.smartalarm.test/cp/assets/browse/aws/accessoires/deur-raamcontact.png/edit",
                        "container": {
                            "id": "aws",
                            "title": "aws",
                            "handle": "aws",
                            "disk": "s3",
                            "blueprint": {
                                "title": "Aws",
                                "handle": "aws"
                            },
                            "search_index": null,
                            "api_url": null
                        },
                        "folder": "accessoires",
                        "url": "https://cdn-smartalarm.s3.eu-central-1.amazonaws.com/accessoires/deur-raamcontact.png",
                        "permalink": "https://cdn-smartalarm.s3.eu-central-1.amazonaws.com/accessoires/deur-raamcontact.png",
                        "api_url": "http://hyper.smartalarm.test/hapi/assets/aws/accessoires/deur-raamcontact.png",
                        "size": "171.50 KB",
                        "size_bytes": 175611,
                        "size_kilobytes": 171.5,
                        "size_megabytes": 0.17,
                        "size_gigabytes": 0,
                        "size_b": 175611,
                        "size_kb": 171.5,
                        "size_mb": 0.17,
                        "size_gb": 0,
                        "last_modified": "2024-11-15T15:29:10.000000Z",
                        "last_modified_timestamp": 1731684550,
                        "last_modified_instance": "2024-11-15T15:29:10.000000Z",
                        "focus": "50-50-1",
                        "has_focus": false,
                        "focus_css": "50% 50%",
                        "height": 800,
                        "width": 1200,
                        "orientation": "landscape",
                        "ratio": 1.5,
                        "mime_type": "image/png",
                        "duration": null,
                        "duration_seconds": null,
                        "duration_minutes": null,
                        "duration_sec": null,
                        "duration_min": null,
                        "playtime": "27:01",
                        "alt": null
                    },
                    "images": {}
                },
                {
                    "key": "example",
                    "variant": "example",
                    "price": "€10.00",
                    "download_limit": null,
                    "downloadable_asset": {},
                    "price_from": "€12.00",
                    "rent_price": "€1.00",
                    "rent_price_from": null,
                    "image": {
                        "id": "aws::accessoires/deur-raamcontact.png",
                        "title": "deur-raamcontact.png",
                        "path": "accessoires/deur-raamcontact.png",
                        "filename": "deur-raamcontact",
                        "basename": "deur-raamcontact.png",
                        "extension": "png",
                        "is_asset": true,
                        "is_audio": false,
                        "is_previewable": false,
                        "is_image": true,
                        "is_svg": false,
                        "is_video": false,
                        "blueprint": {
                            "title": "Aws",
                            "handle": "aws"
                        },
                        "edit_url": "http://hyper.smartalarm.test/cp/assets/browse/aws/accessoires/deur-raamcontact.png/edit",
                        "container": {
                            "id": "aws",
                            "title": "aws",
                            "handle": "aws",
                            "disk": "s3",
                            "blueprint": {
                                "title": "Aws",
                                "handle": "aws"
                            },
                            "search_index": null,
                            "api_url": null
                        },
                        "folder": "accessoires",
                        "url": "https://cdn-smartalarm.s3.eu-central-1.amazonaws.com/accessoires/deur-raamcontact.png",
                        "permalink": "https://cdn-smartalarm.s3.eu-central-1.amazonaws.com/accessoires/deur-raamcontact.png",
                        "api_url": "http://hyper.smartalarm.test/hapi/assets/aws/accessoires/deur-raamcontact.png",
                        "size": "171.50 KB",
                        "size_bytes": 175611,
                        "size_kilobytes": 171.5,
                        "size_megabytes": 0.17,
                        "size_gigabytes": 0,
                        "size_b": 175611,
                        "size_kb": 171.5,
                        "size_mb": 0.17,
                        "size_gb": 0,
                        "last_modified": "2024-11-15T15:29:10.000000Z",
                        "last_modified_timestamp": 1731684550,
                        "last_modified_instance": "2024-11-15T15:29:10.000000Z",
                        "focus": "50-50-1",
                        "has_focus": false,
                        "focus_css": "50% 50%",
                        "height": 800,
                        "width": 1200,
                        "orientation": "landscape",
                        "ratio": 1.5,
                        "mime_type": "image/png",
                        "duration": null,
                        "duration_seconds": null,
                        "duration_minutes": null,
                        "duration_sec": null,
                        "duration_min": null,
                        "playtime": "27:01",
                        "alt": null
                    },
                    "images": {}
                }
            ]
        },
        ...

Screencast https://drive.google.com/file/d/1GOTOFqJ-JQ3dW1VbiYObGWg8OcWJfgeJ/view?usp=sharing

When doing a dd($entry) in laravel, the data is there Screenshot 2024-11-19 at 10 40 02

Steps to reproduce

  1. Install simple-commerce
  2. Add product-variants
  3. Add "asset" field to product variant (where max files is empty)
  4. Upload images and fetch through REST API

Environment

Environment Application Name: Statamic Laravel Version: 11.30.0 PHP Version: 8.3.13 Composer Version: 2.7.7 Environment: local Debug Mode: ENABLED URL: kenarie.test Maintenance Mode: OFF Timezone: UTC Locale: en

Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED

Drivers Broadcasting: log Cache: file Database: sqlite Logs: stack / single Mail: log Queue: sync Session: file

Simple Commerce Currencies: EUR Gateways: Dummy Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Free Shipping Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine

Statamic Addons: 1 Sites: 1 Stache Watcher: Enabled (auto) Static Caching: Disabled Version: 5.37.0 PRO

Statamic Addons duncanmcclean/simple-commerce: 7.5.4

github-actions[bot] commented 1 week ago

Released as part of v7.5.5.