Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shopify-default_variant

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shopify-default_variant

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Shopify::DefaultVariant

CI

Determine if the given Shopify product only has a default variant, or if the given variant is the default variant.

Works with a variety of objects:

  • ShopifyAPI gem response objects
  • GraphQL response Hash with String or Symbol keys
  • Plain Ol' Ruby Object (PORO)
  • Plain Hash with String or Symbol keys

Usage

Shopify::DefaultVariant.match?(object)

Where object can be a product or a variant in any of the aforementioned forms.

More examples:

require "shopify_api"  # Just an example, *not* a recommendation 😉

product = ShopifyAPI::Product.find(id: id)
Shopify::DefaultVariant.match?(product)
Shopify::DefaultVariant.match?(product.variants)
Shopify::DefaultVariant.match?(product.variants.sample)

require "shopify_api-graphql-tiny"

gql = ShopifyAPI::GraphQL::Tiny.new("shop", "token")

data = gql.execute(YOUR_QUERY)
# Be sure to remove the data key and query's name key (whatever it may be)
Shopify::DefaultVariant.match?(data.dig("data", "queryName"))

# Or use a Object or Hash that resembles one of the well-known forms
Shopify::DefaultVariant.match?(my_custom_object)

Testing

The GraphQL tests require a Shopify store and access token. You can set this by copying .env.template to .env.test and adding the appropriate values. VCR is used to record these requests.


Made by ScreenStaring

FAQs

Package last updated on 03 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc