You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating or updating products and their variants, you can specify prices in multiple currencies using the `currency_prices` array property. Each entry in this array should include:
604
+
### Set Variant Price in Specific Currency
605
605
606
-
-`currency_code`: The three-letter ISO code of the currency (e.g., "USD", "EUR", "GBP")
607
-
-`price`: The price in the specified currency
608
-
-`compare_price` (optional): The compare price (original/before discount price) in the specified currency
606
+
```plaintext
607
+
POST /api/admin/variants/{variant_id}/prices
608
+
```
609
+
610
+
**Request Body:**
611
+
612
+
```json
613
+
{
614
+
"currency_code": "DKK",
615
+
"price": 250.0
616
+
}
617
+
```
618
+
619
+
**Response Body:**
620
+
621
+
```json
622
+
{
623
+
"id": 1,
624
+
"product_id": 1,
625
+
"sku": "PROD-001-RED",
626
+
"price": 25.0,
627
+
"currency": "USD",
628
+
"stock": 10,
629
+
"attributes": [
630
+
{
631
+
"name": "Color",
632
+
"value": "Red"
633
+
}
634
+
],
635
+
"images": [],
636
+
"is_default": true,
637
+
"created_at": "2025-06-20T10:00:00Z",
638
+
"updated_at": "2025-06-20T10:30:00Z",
639
+
"prices": {
640
+
"USD": 25.0,
641
+
"DKK": 250.0
642
+
}
643
+
}
644
+
```
645
+
646
+
**Status Codes:**
647
+
648
+
-`200 OK`: Price set successfully
649
+
-`400 Bad Request`: Invalid request body or currency not enabled
650
+
-`401 Unauthorized`: Not authenticated
651
+
-`403 Forbidden`: Not authorized (not an admin)
652
+
-`404 Not Found`: Variant or currency not found
653
+
654
+
### Set Multiple Variant Prices
655
+
656
+
```plaintext
657
+
PUT /api/admin/variants/{variant_id}/prices
658
+
```
659
+
660
+
**Request Body:**
661
+
662
+
```json
663
+
{
664
+
"prices": {
665
+
"USD": 25.0,
666
+
"EUR": 21.25,
667
+
"DKK": 250.0
668
+
}
669
+
}
670
+
```
671
+
672
+
**Response Body:**
673
+
674
+
```json
675
+
{
676
+
"id": 1,
677
+
"product_id": 1,
678
+
"sku": "PROD-001-RED",
679
+
"price": 25.0,
680
+
"currency": "USD",
681
+
"stock": 10,
682
+
"attributes": [
683
+
{
684
+
"name": "Color",
685
+
"value": "Red"
686
+
}
687
+
],
688
+
"images": [],
689
+
"is_default": true,
690
+
"created_at": "2025-06-20T10:00:00Z",
691
+
"updated_at": "2025-06-20T10:30:00Z",
692
+
"prices": {
693
+
"USD": 25.0,
694
+
"EUR": 21.25,
695
+
"DKK": 250.0
696
+
}
697
+
}
698
+
```
699
+
700
+
**Status Codes:**
701
+
702
+
-`200 OK`: Prices set successfully
703
+
-`400 Bad Request`: Invalid request body or one or more currencies not enabled
704
+
-`401 Unauthorized`: Not authenticated
705
+
-`403 Forbidden`: Not authorized (not an admin)
706
+
-`404 Not Found`: Variant not found
707
+
708
+
### Get Variant Prices
709
+
710
+
```plaintext
711
+
GET /api/variants/{variant_id}/prices
712
+
```
713
+
714
+
**Response Body:**
715
+
716
+
```json
717
+
{
718
+
"prices": {
719
+
"USD": 25.0,
720
+
"EUR": 21.25,
721
+
"DKK": 250.0
722
+
}
723
+
}
724
+
```
609
725
610
-
The system always requires a price in the default currency, and additional currency prices are optional. If a currency price is not specified for a particular currency, the system will automatically convert the price from the default currency using the current exchange rate when needed.
726
+
**Status Codes:**
611
727
612
-
### Retrieving Products with Specific Currency Prices
728
+
-`200 OK`: Prices retrieved successfully
729
+
-`404 Not Found`: Variant not found
613
730
614
-
When retrieving products, you can specify a currency code in the query parameters to get prices in that currency:
This will return the product with prices in euros, either using the explicitly set euro prices or converting from the default currency if no specific euro prices are set.
764
+
**Status Codes:**
765
+
766
+
-`200 OK`: Price removed successfully
767
+
-`400 Bad Request`: Cannot remove default currency price
768
+
-`401 Unauthorized`: Not authenticated
769
+
-`403 Forbidden`: Not authorized (not an admin)
770
+
-`404 Not Found`: Variant not found or price not set for this currency
771
+
772
+
## Benefits of Multi-Currency Pricing
773
+
774
+
### Precision and Accuracy
775
+
776
+
-**No conversion errors**: Set exact prices in each currency to avoid floating-point precision issues
777
+
-**Local pricing**: Set appropriate prices for each market without relying on exchange rate calculations
778
+
-**Price consistency**: Ensure consistent pricing across all customer touchpoints
779
+
780
+
### Checkout Integration
621
781
622
-
## Example Workflow
782
+
-**Automatic price selection**: When customers checkout in a specific currency, the system automatically uses the exact price set for that currency
783
+
-**Fallback conversion**: If no specific price is set for a currency, the system falls back to conversion from the default currency
784
+
-**Currency parameter**: API clients can specify the desired checkout currency as a parameter
623
785
624
-
### Product Management Flow (Seller)
786
+
### Example Use Case
625
787
626
-
1. Seller creates a base product through the seller interface
627
-
2. If the product has variants, seller adds variants with different attributes (color, size, etc.)
628
-
3. Seller can update product information or variant details as needed
629
-
4. Seller can manage inventory levels for products and variants
630
-
5. Seller can deactivate or delete products when they're no longer available
788
+
A product originally priced at 25.00 USD might be set to exactly:
631
789
632
-
### Product Shopping Flow (Customer)
790
+
- 250.00 DKK (instead of 249.96 DKK from conversion)
791
+
- 21.25 EUR (instead of 21.24 EUR from conversion)
792
+
- 19.99 GBP (psychological pricing)
633
793
634
-
1. Customers browse products by category or use the search function
635
-
2. Customers can view detailed product information including available variants
636
-
3. When adding to checkout, customers select specific variants if the product has them
637
-
4. Products and variants are displayed with current inventory levels
638
-
5. Out-of-stock products or variants can be marked as unavailable for purchase
794
+
This eliminates the reported issue where a 250 DKK product was showing as 249.89 DKK due to conversion precision problems.
0 commit comments