You are here

public function MailchimpEcommerce::addProduct in Mailchimp 8

Add a product to a store.

Parameters

string $store_id: The store id.

string $id: A unique identifier for the product.

string $title: The title of a product.

array $variants: An array of the product’s variants.

  • id (string) A unique identifier for the product variant.
  • title (string) The title of a product variant.

array $parameters: An array of additional parameters. See API docs.

Return value

object The API Product response object.

Throws

\Mailchimp\MailchimpAPIException

See also

http://developer.mailchimp.com/documentation/mailchimp/reference/ecommer...

File

lib/mailchimp-api-php/src/MailchimpEcommerce.php, line 824

Class

MailchimpEcommerce
Mailchimp Ecommerce library.

Namespace

Mailchimp

Code

public function addProduct($store_id, $product_id, $title, $url, $variants = [], $parameters = []) {
  $tokens = [
    'store_id' => $store_id,
  ];
  $parameters += [
    'id' => $product_id,
    'title' => $title,
    'url' => $url,
    'variants' => $variants,
  ];
  return $this
    ->request('POST', '/ecommerce/stores/{store_id}/products', $tokens, $parameters);
}