Skip to content

Commit

Permalink
#297 Updated OpenGraph Product attributes (#299)
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Brk committed May 9, 2023
1 parent 40068ef commit 99744ea
Showing 1 changed file with 39 additions and 6 deletions.
45 changes: 39 additions & 6 deletions src/SEOTools/OpenGraph.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ public function setPlace($attributes = [])

/**
* Set product properties.
* Reference: https://developers.facebook.com/docs/marketing-api/catalog/reference/#example-feeds
*
* @param array $attributes opengraph product attributes
*
Expand All @@ -652,25 +653,57 @@ public function setPlace($attributes = [])
public function setProduct($attributes = [])
{
$validkeys = [
// Required
'brand',
'availability',
'condition',

// Conditionally required
'locale',
'plural_title',

// Conditionally required: https://developers.facebook.com/docs/payments/product/
'price:amount', // Required if Static Pricing & not Dynamic Pricing
'price:currency', // Required if Static Pricing & not Dynamic Pricing

// Optional
'catalog_id',
'item_group_id',
'category',
'gender',
'gtin',
'isbn',
'mfr_part_no',

'sale_price:amount',
'sale_price:currency',
'sale_price_dates:start',
'sale_price_dates:end',


// Optional - extra
'custom_label_0',
'custom_label_1',
'custom_label_2',
'custom_label_3',
'custom_label_4',


// Deprecated
'original_price:amount',
'original_price:currency',
'pretax_price:amount',
'pretax_price:currency',
'price:amount',
'price:currency',
'shipping_cost:amount',
'shipping_cost:currency',
'weight:value',
'weight:units',
'shipping_weight:value',
'shipping_weight:units',
'sale_price:amount',
'sale_price:currency',
'sale_price_dates:start',
'sale_price_dates:end'
];

$this->setProperties('product', 'productProperties', $attributes, $validkeys);

return $this;
}

Expand Down

0 comments on commit 99744ea

Please sign in to comment.