首页 > 解决方案 > BigCommerce 购物车重定向网址

问题描述

我使用 BigCommerce v3 API 创建购物车重定向 url https://developer.bigcommerce.com/api/v3/#/reference/cart/server-to-server-cart/create-redirect-url 有 2 个链接(cart_url 和 checkout_url )。当我尝试使用购物车链接时,我得到了购物车页面,其中包含空购物车和错误消息“无法检索您的购物车。请单击此处继续购物。” 有没有人遇到过同样的情况?

import json
import requests

headers = {
  'Accept': 'application/json',
  'Content-Type': 'application/json',
  'X-Auth-Client': '***',
  'X-Auth-Token': '***'
}
store = '***'
cart_uuid = '********-****-****-****-************'
url = 'https://api.bigcommerce.com/stores/{}/v3/carts/{}/redirect_urls'.format(store, cart_uuid)

response = requests.post(url, headers=headers)
response_dict = json.loads(r.text)

标签: bigcommerce

解决方案


要制作购物车重定向 URL,有两种方法:

  1. 创建购物 https://api.bigcommerce.com/stores/{$$.env.store_hash}/v3/carts?include=redirect_urls 车时:redirect_urls作为包含传入。
  2. 创建购物车后: https://api.bigcommerce.com/stores/{$$.env.store_hash}/v3/carts/{cartId}/redirect_urls用作请求 urlredirect_urls的一部分,以及cartId.

确保将 cartId 替换为 /POST Cart 响应中返回的 id。还要通过对购物车 ID执行/GET 请求来确保购物车仍然有效。

购物车仅在 30 天内有效。


推荐阅读