Giftcard integration

Created on 16 March 2023, about 2 years ago

Problem/Motivation

This task is about providing JSONAPI resources to add/remove giftcards from an order.

The way I see it, we should mimic what was done for coupons and provide 2 new endpoints:

  1. PATCH /jsonapi/carts/{commerce_order}/giftcards
  2. DELETE /jsonapi/carts/{commerce_order}/giftcards

The Giftcard implementation is very similar to the coupons one.
One thing I'm wondering is whether we should return the order itself (which is the option I prefer), or just be consistent with coupons and simply return the relationship).

Also... Should we provide a submodule (commerce_api_giftcard)? Or just provide the routes conditionally, just like it's done for Coupons (albeit coupons are in core), or just like it's done for Wishlist routes (wishlist is also contrib).

Again here, we should probably be consistent, and not go with a submodule, considering we might refactor the current structure and move the JSONAPI integration to a commerce_api_jsonapi module as suggested in #3316766: Generalize this module .

Patch to follow.

Feature request
Status

Needs review

Version

1.0

Component

Code

Created by

🇮🇱Israel jsacksick

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

  • Issue created by @jsacksick
  • Status changed to Needs review about 2 years ago
  • 🇮🇱Israel jsacksick

    I decided to be consistent with coupons (code is very similar).

    Note that for the GC to be properly validated, a constraint should be added to the giftcards reference field, similar to the CouponValid constraint.

Production build 0.71.5 2024