Sha256: 8a03cbb8897c1d06f5ce5b81c76bd0e3e6eec5025f904f23d7910f6a95575953
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
module ShopifyAPI class Product < Base include Events include Metafields early_july_pagination_release! # compute the price range def price_range prices = variants.collect(&:price).collect(&:to_f) format = "%0.2f" if prices.min != prices.max "#{format % prices.min} - #{format % prices.max}" else format % prices.min end end def total_inventory=(new_value) raise_deprecated_inventory_call('total_inventory') unless allow_inventory_params? super end def serializable_hash(options = {}) allow_inventory_params? ? super(options) : super(options).except('total_inventory') end def collections CustomCollection.find(:all, :params => {:product_id => self.id}) end def smart_collections SmartCollection.find(:all, :params => {:product_id => self.id}) end def add_to_collection(collection) collection.add_product(self) end def remove_from_collection(collection) collection.remove_product(self) end private def raise_deprecated_inventory_call(parameter) raise(ShopifyAPI::ValidationException, "'#{parameter}' is deprecated - see https://help.shopify.com/en/api/guides/inventory-migration-guide", ) end def allow_inventory_params? Base.api_version < ApiVersion.find_version('2019-10') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shopify_api-9.2.0 | lib/shopify_api/resources/product.rb |