Module: ShopifyAPI::Metafields

Included in:
Article, Blog, CustomCollection, Customer, Order, Page, Product, SmartCollection, Variant
Defined in:
lib/shopify_api/metafields.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_metafield(metafield)

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
# File 'lib/shopify_api/metafields.rb', line 7

def add_metafield(metafield)
  raise ArgumentError, "You can only add metafields to resource that has been saved" if new?

  metafield.prefix_options = {
    :resource => self.class.collection_name,
    :resource_id => id
  }
  metafield.save
  metafield
end

- (Object) metafields



3
4
5
# File 'lib/shopify_api/metafields.rb', line 3

def metafields
  Metafield.find(:all, :params => {:resource => self.class.collection_name, :resource_id => id})
end