Forum
Pass product variant to Stripe meta data
The following is code I've been using for a while now to pass on to stripe details about the order as meta data. I've just tried to add the product variant information but I get an undefined index on productVariantDesc
. If I do a print_r
of $cart_items
I see the information I want listed under productVariantDesc
so that's where I got that from. (Title and SKU work fine)
$cart = perch_shop_cart(['skip-template'=>true]);
$cart_items = $cart['items'];
foreach($cart_items as $item) {
$product_titles[] = $item['title'];
$product_skus[] = $item['sku'];
$product_variants[] = $item['productVariantDesc'];
}
$product_title = implode(', ', $product_titles);
$product_sku = implode(', ', $product_skus);
$product_variant = implode(', ', $product_variants);
What are you then doing with
$cart_items
?Passing it in to the stripe meta data
Hello Stephen,
$item['productVariantDesc']
doesn't exist indeed. APerchShop_Product
object$item['Product']
should.Though I think the
productVariantDesc
is returned in a protected property so you wouldn't be able to get it this way as far as I know.