Skip to content

Wrong cart and line items cost - total and subtotal #452

Description

@hagsonz

Discussed in #430

Originally posted by hagsonz January 23, 2024
Using product discount. for the cart, I am getting same amount for the total and subtotal fields. in addition, tax and duty values are null.
also, if i have a coupon applied, the Input is still the exact same.

for the line items, the item which is discounted by the function is with full price which is logical as the function haven't applied the discount yet. but the one which is discounted by a coupon, is still with full price.

how can i calculate the correct amount of the cart and line items?

image image

Input (STDIN)

{
  "presentmentCurrencyRate": "1.0",
  "cart": {
    "cost": {
      "subtotalAmount": {
        "amount": "1500.0",
        "currencyCode": "ILS"
      },
      "totalAmount": {
        "amount": "1500.0",
        "currencyCode": "ILS"
      },
      "totalTaxAmount": null,
      "totalDutyAmount": null
    },
    "lines": [
      {
        "id": "gid://shopify/CartLine/0",
        "quantity": 1,
        "cost": {
          "totalAmount": {
            "amount": "600.0",
            "currencyCode": "ILS"
          },
          "subtotalAmount": {
            "amount": "600.0",
            "currencyCode": "ILS"
          }
        },
        "merchandise": {
          "__typename": "ProductVariant",
          "id": "gid://shopify/ProductVariant/44579562455318",
          "product": {
            "id": "gid://shopify/Product/8218915930390"
          }
        },
        "attribute": null
      },
      {
        "id": "gid://shopify/CartLine/1",
        "quantity": 1,
        "cost": {
          "totalAmount": {
            "amount": "900.0",
            "currencyCode": "ILS"
          },
          "subtotalAmount": {
            "amount": "900.0",
            "currencyCode": "ILS"
          }
        },
        "merchandise": {
          "__typename": "ProductVariant",
          "id": "gid://shopify/ProductVariant/44579562881302",
          "product": {
            "id": "gid://shopify/Product/8218916258070"
          }
        },
        "attribute": {
          "key": "_order_bump_offer_id",
          "value": "7MWcCsmycOQbf4kZZStQx"
        }
      }
    ]
  },
  "discountNode": {
    "metafield": {
      "value": "{\"offers\":[{\"expanded\":true,\"enabled\":true,\"offerName\":\"Edit this offer name\",\"layout\":\"vertical\",\"cardLayout\":\"vertical\",\"minCartQuantity\":\"1\",\"maxCartQuantity\":\"601\",\"minCartValue\":0,\"maxCartValue\":\"1000\",\"products\":[\"gid://shopify/Product/8218916258070\"],\"onlyProducts\":[],\"discountAmount\":\"10\",\"discountType\":\"percentage\",\"cartMessage\":\"Edit me\",\"offerType\":\"product\",\"id\":\"7MWcCsmycOQbf4kZZStQx\"},{\"expanded\":true,\"enabled\":false,\"offerName\":\"Edit this offer name\",\"layout\":\"vertical\",\"cardLayout\":\"horizontal\",\"minCartQuantity\":0,\"maxCartQuantity\":99999,\"minCartValue\":0,\"maxCartValue\":100000,\"products\":[\"gid://shopify/Product/8218916126998\",\"gid://shopify/Product/8218916192534\",\"gid://shopify/Product/8218915963158\"],\"onlyProducts\":[],\"discountAmount\":\"5\",\"discountType\":\"percentage\",\"cartMessage\":\"Edit me\",\"offerType\":\"product\",\"id\":\"1wpsj73LB5LO_Ir9dSNzE\"}]}"
    }
  }
}
</div>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions