### Creating New Drupal Commerce Site with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/install.rst This command initializes a new Drupal 8 project with Drupal Commerce 2.x and all its dependencies. It downloads the project base into a specified directory, 'mystore' in this example, setting up a complete environment for a new Commerce site. ```Shell composer create-project drupalcommerce/project-base mystore --stability dev ``` -------------------------------- ### Installing Drupal Commerce Project Base with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/contributing/development-environment.rst This command initializes a new Drupal 8 project with Commerce 2.x and all its dependencies into the 'mystore' folder. The --prefer-source option ensures that Composer uses Git clone for downloading, which is beneficial for development and contribution workflows. ```Bash composer create-project drupalcommerce/project-base mystore --prefer-source --stability dev ``` -------------------------------- ### Downloading Drupal Commerce Project with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/contributing/development-environment.rst.txt This command uses Composer to create a new Drupal 8 project with Drupal Commerce 2.x, downloading all dependencies into the 'mystore' folder. The '--prefer-source' option ensures Git clone is used for downloads, and users should decline removing VCS history to preserve module repositories. ```Bash composer create-project drupalcommerce/project-base mystore --prefer-source --stability dev ``` -------------------------------- ### Creating New Drupal Commerce Project with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/install.html This command uses Composer to create a new Drupal project, `mystore`, pre-configured with Drupal 8 and Drupal Commerce 2.x. It downloads all necessary dependencies and sets up the project base, making it ready for installation as a regular Drupal site. The `--stability dev` flag allows for development versions. ```Bash composer create-project drupalcommerce/project-base mystore --stability dev ``` -------------------------------- ### Adding New Drupal Modules via Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/contributing/development-environment.rst.txt This Composer command demonstrates how to add an additional Drupal module, 'devel' in this example, to the project. It specifies the module name and version constraint. ```Bash composer require "drupal/devel:1.x-dev" ``` -------------------------------- ### Executing Drupal Commerce PHPUnit Tests Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/contributing/development-environment.rst.txt This command navigates to the 'web' directory of the Drupal installation and then executes PHPUnit tests specifically for the Drupal Commerce module. It uses the core PHPUnit configuration file and targets the commerce module's test suite. ```Bash cd mystore/web # Run PHPUnit tests ../bin/phpunit -c core/phpunit.xml modules/contrib/commerce ``` -------------------------------- ### Creating New Drupal Commerce Project with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/install.rst.txt This command initializes a new Drupal 8 project with Commerce 2.x and all its dependencies. It downloads the project base into the specified 'mystore' directory, setting up a ready-to-install Drupal site with Commerce automatically enabled. ```Shell composer create-project drupalcommerce/project-base mystore --stability dev ``` -------------------------------- ### Defining Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started.html This JavaScript snippet defines global configuration options for the documentation system, including root URL, version, file suffixes, and source link settings. It's typically used by the documentation generator (Sphinx) to manage relative paths and features. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Adding New Drupal Modules via Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/contributing/development-environment.rst This Composer command allows developers to download and integrate additional Drupal modules, such as 'devel', into their project. It specifies the module name and version constraint for installation. ```Bash composer require "drupal/devel:1.x-dev" ``` -------------------------------- ### Creating a Store using Drupal Console Command Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/store.rst This command provides a quick shortcut to create a new store in Drupal Commerce 2 using the Drupal Console. It automates the initial setup process, allowing developers to bypass the user interface for basic store creation. This is useful for rapid development or scripting store setups. ```Shell drupal commerce:create:store ``` -------------------------------- ### Creating a Store using Drupal Console Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/store.rst.txt This command-line shortcut allows for quick creation of a new store in Drupal Commerce 2, streamlining the initial setup process. It serves as an efficient alternative to the user interface method for store creation. ```Drupal Console drupal commerce:create:store ``` -------------------------------- ### Downloading Additional Drupal Modules with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This Composer command is used to download and add additional Drupal modules to an existing project. It specifies the module name (`drupal/devel`) and its version constraint (`1.x-dev`). This command should be run from the site's root directory. ```Bash composer require "drupal/devel:1.x-dev" ``` -------------------------------- ### Defining Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This JavaScript snippet initializes the global `DOCUMENTATION_OPTIONS` object, which configures various parameters for the documentation system. It sets the root URL, version, index collapsing behavior, file suffixes, and source link suffixes. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Adding a GitHub Fork Remote for Drupal Commerce Contributions Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/contributing/development-environment.rst This sequence of commands navigates into the Commerce module directory and adds a new Git remote pointing to your personal GitHub fork. This setup is crucial for pushing changes to your fork and subsequently creating pull requests against the main repository. ```Bash cd web/modules/contrib/commerce git remote add fork git@github.com:YOUR_USER/commerce.git ``` -------------------------------- ### Running Drupal Commerce PHPUnit Tests Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This sequence of commands navigates to the `web` directory of the Drupal Commerce project and then executes PHPUnit tests specifically for the `commerce` module. It uses the `phpunit.xml` configuration file from Drupal core. This allows developers to verify the functionality and stability of the Commerce module. ```Bash cd mystore/web ../bin/phpunit -c core/phpunit.xml modules/contrib/commerce ``` -------------------------------- ### Enabling Drupal Commerce Modules with Drupal Console Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/install.rst After downloading, this Drupal Console command enables the core Drupal Commerce modules: commerce_product, commerce_checkout, commerce_cart, and commerce_tax. This activates the primary e-commerce functionalities on the Drupal site. ```Shell drupal module:install commerce_product commerce_checkout commerce_cart commerce_tax ``` -------------------------------- ### Adding a Git Remote for a Forked Commerce Repository Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/contributing/development-environment.rst.txt This sequence of Git commands navigates into the Commerce module directory and adds a new remote named 'fork'. This remote points to the user's personal GitHub fork, enabling pushing new branches for contributions. ```Bash cd web/modules/contrib/commerce git remote add fork git@github.com:YOUR_USER/commerce.git ``` -------------------------------- ### Downloading Drupal Commerce 2.x Project Base with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This Composer command downloads Drupal 8 and Drupal Commerce 2.x, along with all their dependencies, into a new directory named `mystore`. The `--prefer-source` option ensures that Git clone is used for downloading, and `--stability dev` allows for development versions. It's crucial to answer 'n' when prompted to remove VCS history to retain Git repositories within contrib modules. ```Bash composer create-project drupalcommerce/project-base mystore --prefer-source --stability dev ``` -------------------------------- ### Updating Existing Drupal Modules via Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/contributing/development-environment.rst.txt This Composer command updates a specific Drupal module, 'drupal/address', along with its dependencies. It's used to refresh a module to its latest compatible version. ```Bash composer update drupal/address ``` -------------------------------- ### Downloading Drupal Commerce for Existing Site with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/install.rst This command downloads the Drupal Commerce 2.x module and all its necessary dependencies, including modules like Address, Entity, State Machine, Inline Entity Form, and Profile, into an existing Drupal 8 site. ```Shell composer require "drupal/commerce 2.x-dev" ``` -------------------------------- ### Executing Drupal Commerce PHPUnit Tests Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/contributing/development-environment.rst This command navigates to the web root and then executes PHPUnit tests specifically for the Drupal Commerce module. It uses the phpunit.xml configuration file from the core directory to define the testing environment and scope. ```Bash cd mystore/web # Run PHPUnit tests ../bin/phpunit -c core/phpunit.xml modules/contrib/commerce ``` -------------------------------- ### Downloading Additional Drupal Modules with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/install.html This Composer command adds the `drupal/devel` module to an existing Drupal project. It specifies the `1.x-dev` version, indicating a development release. This is used to extend the site's functionality by integrating new modules. ```Bash composer require "drupal/devel:1.x-dev" ``` -------------------------------- ### Downloading Additional Drupal Modules with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/install.rst This Composer command adds a new Drupal module, such as 'devel', to an existing Drupal Commerce project. It ensures the module and its required dependencies are properly downloaded and integrated into the site's codebase. ```Shell composer require "drupal/devel:1.x-dev" ``` -------------------------------- ### Configuring Sphinx Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/install-a-payment-gateway.html This JavaScript snippet defines global configuration options for the Sphinx documentation system. It sets parameters such as the root URL, documentation version, file suffixes, and source linking behavior, which are essential for the documentation's internal navigation and asset loading. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Adding New Modules to Drupal Commerce Site with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/install.rst.txt This command uses Composer to download and add a new Drupal module (e.g., 'devel') to an existing Drupal Commerce project. It ensures the module and its dependencies are correctly integrated into the project's vendor directory. ```Shell composer require "drupal/devel:1.x-dev" ``` -------------------------------- ### Downloading Drupal Commerce to Existing Site with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/install.rst.txt This command downloads the Drupal Commerce module and all its core dependencies (like Address, Entity, State Machine, Inline Entity Form, Profile) into an existing Drupal 8 site. It integrates Commerce's files into the project's vendor directory, preparing it for enablement. ```Shell composer require "drupal/commerce 2.x-dev" ``` -------------------------------- ### Configuring Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/product-attributes.html This JavaScript snippet defines global configuration options used by the documentation system, such as the root URL, version, and source link suffix. It's typically found in the header of documentation pages to set up dynamic behaviors and paths for assets. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Updating Existing Drupal Modules via Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/contributing/development-environment.rst This command updates a specific Drupal module, like 'address', along with its dependencies. It ensures that the module is brought to its latest compatible version as defined in the project's composer.json. ```Bash composer update drupal/address ``` -------------------------------- ### Updating Existing Drupal Modules with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/install.rst This command updates a specific Drupal module, for instance 'drupal/address', along with its dependencies, to the latest compatible version within the project. It's essential for maintaining module security and functionality. ```Shell composer update drupal/address ``` -------------------------------- ### Updating Existing Drupal Modules with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/install.rst.txt This command updates a specific Drupal module (e.g., 'drupal/address') and its dependencies to their latest compatible versions within the project. It helps maintain module currency and resolve potential security or compatibility issues. ```Shell composer update drupal/address --with-dependencies ``` -------------------------------- ### Updating an Existing Drupal Module with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This Composer command updates a specific Drupal module (`drupal/address`) and its dependencies. It ensures that the module is brought up to its latest compatible version based on the project's `composer.json` constraints. This command should be executed from the site's root directory. ```Bash composer update drupal/address --with-dependencies ``` -------------------------------- ### Downloading Drupal Commerce for Existing Site with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/install.html This Composer command downloads the Drupal Commerce module (version `2.x-dev`) and its required dependencies (e.g., Address, Entity, State Machine, Inline Entity Form, Profile) into an existing Drupal project. It integrates the core Commerce functionality into the site's codebase. ```Bash composer require "drupal/commerce 2.x-dev" ``` -------------------------------- ### Toggling Mobile Navigation with jQuery Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started.html This jQuery snippet handles the click event for a mobile toggle button. When clicked, it toggles the visibility of the left-column element, likely a navigation sidebar, providing a responsive design feature. ```JavaScript $("#mobile-toggle a").click(function () { $("#left-column").toggle(); }); ``` -------------------------------- ### Adding Drupal Packagist Repository to Composer Configuration Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/install.rst.txt This command configures Composer to recognize the official Drupal Packagist repository. This is a prerequisite for downloading Drupal-specific modules and themes, allowing Composer to locate Commerce and other Drupal dependencies. ```Shell composer config repositories.drupal composer https://packages.drupal.org/8 ``` -------------------------------- ### Adding Drupal Packagist Repository to Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/install.rst This command configures Composer to recognize the official Drupal Packagist repository. This step is crucial for Composer to locate and download Drupal-specific modules, themes, and other packages required for Commerce. ```Shell composer config repositories.drupal composer https://packages.drupal.org/8 ``` -------------------------------- ### Updating Existing Drupal Modules with Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/install.html This Composer command updates the `drupal/address` module to its latest compatible version within the project. The `--with-dependencies` flag ensures that any dependent packages of the `address` module are also updated, maintaining compatibility and stability. ```Bash composer update drupal/address –with-dependencies ``` -------------------------------- ### Enabling Drupal Commerce Modules with Drupal Console Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/getting-started/install.rst.txt This command uses Drupal Console to enable the core Drupal Commerce modules, including product, checkout, cart, and tax functionalities. Enabling these modules activates the Commerce features within the Drupal site, making them available for configuration and use. ```Shell drupal module:install commerce_product commerce_checkout commerce_cart commerce_tax ``` -------------------------------- ### Adding GitHub Fork as a Git Remote Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This sequence of Git commands navigates into the Drupal Commerce module directory and adds a new Git remote named `fork`. This remote points to your personal fork of the Commerce repository on GitHub, allowing you to push changes to your fork and create pull requests against the main repository. Replace `YOUR_USER` with your actual GitHub username. ```Bash cd web/modules/contrib/commerce git remote add fork git@github.com:YOUR_USER/commerce.git ``` -------------------------------- ### Enabling Drupal Commerce Modules with Drupal Console Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/install.html This Drupal Console command enables a set of core Drupal Commerce modules: `commerce_product`, `commerce_checkout`, `commerce_cart`, and `commerce_tax`. These modules provide essential e-commerce functionalities like product management, checkout processes, shopping cart, and tax calculation, making the Commerce system operational. ```Bash drupal module:install commerce_product commerce_checkout commerce_cart commerce_tax ``` -------------------------------- ### Adding Drupal Packagist Repository to Composer Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/install.html This command configures Composer to recognize the official Drupal Packagist repository, `https://packages.drupal.org/8`. This is a prerequisite for Composer to locate and download Drupal-specific modules and themes, including Drupal Commerce, when working with an existing Drupal site. ```Bash composer config repositories.drupal composer https://packages.drupal.org/8 ``` -------------------------------- ### Configuring Sphinx Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/building-blocks/address/zones.html This JavaScript snippet initializes the DOCUMENTATION_OPTIONS global object, which is crucial for configuring Sphinx-generated documentation. It sets properties like URL_ROOT for relative paths, VERSION for the documentation version, and FILE_SUFFIX for document file extensions, guiding how the documentation is rendered and linked. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Defining Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/managing-order-payments.html This JavaScript object defines configuration options for the documentation system, likely Sphinx. It specifies the root URL, version, index collapsing behavior, file suffixes, and source link suffix, guiding how the documentation is rendered and linked. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Implementing a Workflow Guard Service in YAML Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/building-blocks/state-machine.rst.txt This YAML snippet defines a service 'mymodule.fulfillment_guard' that acts as a workflow guard. Guards are used to restrict transitions based on custom logic, and this example shows how to tag the service with 'state_machine.guard' and specify the 'group' it applies to, allowing the guard factory to instantiate relevant guards. ```yaml mymodule.fulfillment_guard: class: Drupal\mymodule\Guard\FulfillmentGuard tags: - { name: state_machine.guard, group: order } ``` -------------------------------- ### Creating Products in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/recipes/products.rst This snippet demonstrates how to create a new product entity in Drupal Commerce. It shows how to define the product's 'uid', 'type' (referencing a product type), 'title', associated 'stores', and 'variations'. It also includes an example of adding an additional variation to an already created product using the 'addVariation()' method. ```php /** * uid [Integer] * Foreign key of the user that created the product. * * type [String] - [DEFAULT = default] * Foreign key of the product type being used. * * title [String] * The product title. * * stores [Array(\Drupal\commerce_store\Entity\StoreInterface)] * Array of stores this product belongs to. * * variations [Array(\Drupal\commerce_product\Entity\ProductVariationInterface)] * Array of variations that belong to this product. */ // The variations that belong to this product. $variations = [ $variation_blue_large, ]; $product = \Drupal\commerce_product\Entity\Product::create([ 'uid' => 1, 'type' => 'my_custom_product_type', 'title' => 'My Custom Product', 'stores' => [$store], 'variations' => $variations, ]); $product->save(); // You can also add a variation to a product using the addVariation() method. $product->addVariation($variation_red_medium); $product->save(); ``` -------------------------------- ### Creating Order Items in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/recipes/orders.rst.txt This snippet shows how to create individual order items, which represent specific products or services within an order. It requires the order item type, the purchased entity (e.g., a product variation), quantity, and unit price. The example also demonstrates how to update the quantity and unit price of an existing order item. ```php /** * type [String] - [DEFAULT = product_variation] * Foreign key to use for the order item type. * * purchased_entity [Integer | \Drupal\commerce\PurchasableEntityInterface] * Foreign key to use for the purchased entity. Either the id, or object implementing the interface. * * quantity [Integer] * How many of the purchased items. * * unit_price [\Drupal\commerce_price\Price] * The price per each item, not the total. * * adjustments [OPTIONAL] - [Array(Drupal\commerce_order\Adjustment)] * Array of any price adjustments. */ $order_item = \Drupal\commerce_order\Entity\OrderItem::create([ 'type' => 'custom_order_item_type', 'purchased_entity' => $variation_red_medium, 'quantity' => 2, 'unit_price' => $variation_red_medium->getPrice(), ]); $order_item->save(); // You can set the quantity with setQuantity. $order_item->setQuantity('1'); $order_item->save(); // You can also set the price with setUnitPrice. $unit_price = new \Drupal\commerce_price\Price('9.99', 'USD'); $order_item->setUnitPrice($unit_price); $order_item->save(); ``` -------------------------------- ### Initializing Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/products.html This JavaScript snippet defines global configuration options for the documentation system. It sets paths, version, and other flags necessary for the documentation's functionality, such as root URL, version number, and source link suffix. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Creating a Store using Drupal Console Command (Shell) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/store.html This command provides a shortcut to quickly set up a new store within Drupal Commerce 2.x using the Drupal Console CLI tool. It automates the initial store creation process, bypassing the need to use the user interface. ```Shell drupal commerce:create:store ``` -------------------------------- ### Initializing Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/creating-a-promotion.html This JavaScript snippet initializes global configuration options for the Sphinx-generated documentation. It sets parameters such as the root URL, version number, file suffixes, and source link availability, which are crucial for the documentation's functionality and navigation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/setting-up-payments.html This JavaScript snippet defines global configuration options for the documentation system, likely Sphinx. It specifies relative paths, version, and display settings for the documentation pages, such as file suffixes and source link availability. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Defining Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/introduction.html This JavaScript snippet defines global configuration options for the Sphinx-generated documentation. It sets parameters like the root URL, version, file suffixes, and source link behavior, which are crucial for the proper rendering and navigation of the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Initializing Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/product-type.html This JavaScript snippet initializes global options used by the Sphinx documentation system. It defines paths, version, and display settings for the documentation, crucial for its proper rendering and navigation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Initializing Documentation Global Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/checkout/guest.html This JavaScript snippet defines a global configuration object, DOCUMENTATION_OPTIONS, used by the Sphinx documentation system. It sets essential parameters like the root URL, documentation version, file suffixes, and source link behavior, which are critical for the correct rendering and navigation of the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/index.html This JavaScript snippet defines global configuration options for the documentation system, likely Sphinx. It specifies paths, version, file suffixes, and source linking behavior, crucial for how the documentation is rendered and navigated. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Loading an Order by ID in Drupal Commerce Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/recipes/orders.rst This snippet demonstrates how to load an existing order entity in Drupal Commerce using its primary key (ID). The `load()` method retrieves the order object from the database, allowing further manipulation or display of its details. The example loads the order with ID 1. ```PHP $order = \Drupal\commerce_order\Entity\Order::load(1); ``` -------------------------------- ### Toggle Left Column Visibility (jQuery) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/development-environment.html This JavaScript snippet uses jQuery to attach a click event handler to an anchor tag within an element with the ID 'mobile-toggle'. When clicked, it toggles the visibility of the element with the ID 'left-column', likely used for responsive design or sidebar control. ```JavaScript $("#mobile-toggle a").click(function () { $("#left-column").toggle(); }); ``` -------------------------------- ### Initializing Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/orders/index.html This JavaScript object defines global configuration options for the documentation system, likely Sphinx. It specifies paths, version, index collapsing behavior, file suffixes, and source link settings, which are crucial for the proper rendering and navigation of the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Implementing Mobile Navigation Toggle - jQuery/JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/install-a-payment-gateway.html This jQuery snippet implements a click event handler for a mobile navigation toggle button. When the element with ID 'mobile-toggle' containing an anchor tag is clicked, it toggles the display of the 'left-column' element, typically used for a responsive sidebar menu. ```JavaScript $("#mobile-toggle a").click(function () { $("#left-column").toggle(); }); ``` -------------------------------- ### Configuring Sphinx Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/using-promotions.html This JavaScript snippet defines global configuration variables for a Sphinx-generated documentation site. It sets properties like the root URL, documentation version, index collapse behavior, file suffixes, and source link availability, which are used by the Sphinx frontend to manage navigation and content display. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Committing and Pushing Initial Changes to a Git Fork (Bash) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/developing.html These commands commit all staged changes with a descriptive message linking to the issue, then push the new commits to the developer's forked repository. This makes the changes available for review via a pull request. ```Bash git commit -a -m "Issue 2276369: Fix notice in the product form." git push fork 2276369-fix-product-form-notice ``` -------------------------------- ### Configuring Documentation Options - Sphinx JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/catalog-and-product-pages.html This JavaScript snippet initializes a global DOCUMENTATION_OPTIONS object. It defines various parameters for the Sphinx documentation system, including the root URL, version, index collapse behavior, file suffixes, and source link settings. This object is crucial for the proper rendering and navigation of the documentation pages. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Initializing Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/index.html This JavaScript snippet initializes the `DOCUMENTATION_OPTIONS` global variable. It configures various settings for the documentation system, including the root URL, version, index collapsing behavior, file suffixes, and whether source links are available. This object is a critical dependency for the proper rendering and interactive features of the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Initializing Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/building-blocks/currency.html This JavaScript snippet initializes global documentation options used by Sphinx. It defines paths, version, and display settings for the documentation interface, including the root URL, version number, index collapse behavior, file suffixes, and source link availability. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Toggling Mobile Navigation with jQuery Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/product-attributes.html This JavaScript snippet uses jQuery to attach a click event handler to an anchor tag within an element with the ID 'mobile-toggle'. When clicked, it toggles the visibility of the element with the ID 'left-column', typically used for responsive navigation or sidebar control. It requires jQuery to be loaded as a dependency. ```JavaScript $("#mobile-toggle a").click(function () { $("#left-column").toggle(); }); ``` -------------------------------- ### Defining Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/theme-a-product-page.html This JavaScript snippet defines global configuration options for the documentation system, including the root URL, version, index collapse behavior, file suffixes, and source link settings. These options are typically used by the Sphinx documentation generator to control how documentation pages are rendered and linked. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Creating Blue Large Product Variation in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/recipes/attributes.html This PHP snippet illustrates the creation and saving of another product variation entity in Drupal Commerce. Similar to the previous example, it sets a custom type, SKU 'product-blue-large', a price of $10.00 USD, and associates pre-defined 'blue' color and 'large' size attribute values before saving the entity. ```php $variation_blue_large = \Drupal\commerce_product\Entity\ProductVariation::create([ 'type' => 'my_custom_variation_type', 'sku' => 'product-blue-large', 'price' => new \Drupal\commerce_price\Price('10.00', 'USD'), 'attribute_color' => $blue, 'attribute_size' => $large, ]); $variation_blue_large->save(); ``` -------------------------------- ### Initializing Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/checkout/customize.html This JavaScript snippet initializes a global `DOCUMENTATION_OPTIONS` object, which configures various parameters for the documentation viewer, such as root URL, version, file suffixes, and source link behavior. It's typically used by the documentation generation system (like Sphinx) to manage paths and features. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Defining Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/product/purchasable-entities.html This JavaScript snippet initializes a global `DOCUMENTATION_OPTIONS` object, which configures various parameters for the documentation system, likely Sphinx. It sets the root URL, version, collapse index behavior, file suffixes, and source link suffix, essential for the proper rendering and navigation of the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Defining Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/checkout/index.html This JavaScript snippet defines global configuration options for the Sphinx documentation system. It specifies paths, version, indexing behavior, file suffixes, and source availability, crucial for the documentation's rendering and navigation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Initializing Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/search.html This JavaScript variable `DOCUMENTATION_OPTIONS` is used to configure the Sphinx documentation system. It defines parameters such as the root URL, version, index collapsing behavior, file suffixes, and source link availability. It's a global configuration object for the documentation's front-end behavior. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/orders/order-processing.html This JavaScript snippet initializes the `DOCUMENTATION_OPTIONS` global variable, which holds configuration settings for the Sphinx documentation. It defines parameters such as the root URL, documentation version, index collapse behavior, and file suffixes, essential for the proper rendering and navigation of the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/building-blocks/profile.html This JavaScript variable declaration sets up global configuration options for the documentation system. It specifies the base URL, version number, index collapsing behavior, file suffixes for HTML and source files, and whether source links are available. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/composer.html This JavaScript snippet defines a global variable `DOCUMENTATION_OPTIONS` used to configure the behavior of the Sphinx documentation viewer. It specifies paths, version, index collapse settings, file suffixes, and source link suffixes for the documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/building-blocks/ief.html This JavaScript snippet defines global configuration options for the documentation system, likely Sphinx. It specifies paths, version, file suffixes, and source link settings, which are crucial for proper navigation and linking within the generated documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/genindex.html This JavaScript snippet defines global configuration options for the documentation system, likely Sphinx. It sets parameters such as the root URL, version number, index collapse behavior, file suffixes, and source link availability, influencing how the documentation is rendered and navigated. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: './', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/building-blocks/index.html This JavaScript object defines global configuration options for the documentation system. It specifies paths, version, display settings, and source file suffixes, used to control how the documentation is rendered and linked. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Defining Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/building-blocks/address/README.html This JavaScript snippet initializes the global `DOCUMENTATION_OPTIONS` object, which is crucial for the Sphinx documentation system. It sets parameters like the base URL for relative paths, the documentation version, and suffixes for source and HTML files, ensuring proper navigation and linking within the generated documentation. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Configuring Documentation Viewer Options (JavaScript) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/recipes/orders.html This JavaScript snippet initializes the `DOCUMENTATION_OPTIONS` global variable, which is crucial for configuring how documentation is rendered or navigated. It sets parameters like the root URL, version, index collapsing behavior, file suffixes, and whether source links are available. ```JavaScript var DOCUMENTATION\_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Initializing Documentation Options - JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/orders/order-types.html This JavaScript snippet defines global configuration options for the documentation system. It sets parameters such as the root URL, version, index collapsing behavior, file suffixes, and source link availability, which are used internally by the documentation rendering engine. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Creating a Store in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/recipes/stores.html This snippet demonstrates how to create a new store entity. It defines an address array and currency, imports the currency if needed, then uses `Store::create()` with parameters like `type`, `uid`, `name`, `mail`, `address`, `default_currency`, and `billing_countries`. Finally, it saves the store and optionally marks it as the default store for the site. ```PHP /** * type [String] - [DEFAULT = 'online'] * Foreign key for the store type to yse. * * uid [Integer] * The user id that created the store. * * name [String] * The store's name. * * mail [String] * The store's email address. * * address [\Drupal\address\AddressInterface] * The store's address. * * default_currency [String] * The currency the store uses. * * billing_countries [Array(String)] * Array of country codes selected for the store. */ // The store's address. $address = [ 'country_code' => 'US', 'address_line1' => '123 Street Drive', 'locality' => 'Beverly Hills', 'administrative_area' => 'CA', 'postal_code' => '90210', ]; // The currency code. $currency = 'USD'; // If needed, this will import the currency. $currency_importer = \Drupal::service('commerce_price.currency_importer'); $currency_importer->import($currency); $store = \Drupal\commerce_store\Entity\Store::create([ 'type' => 'custom_store_type', 'uid' => 1, 'name' => 'My Store', 'mail' => 'admin@example.com', 'address' => $address, 'default_currency' => $currency, 'billing_countries' => ['US'], ]); $store->save(); // If needed, this sets the store as the default store. $store_storage = \Drupal::service('entity_type.manager')->getStorage('commerce_store'); $store_storage->markAsDefault($store); ``` -------------------------------- ### Running Drupal Database Updates via Command Line (Shell) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/getting-started/update.rst These commands are used to apply pending Drupal database updates after module and dependency updates. `drupal update:debug` shows available updates, and `drupal update:execute` applies them, which is recommended over using `update.php`. ```sh drupal update:debug drupal update:execute ``` -------------------------------- ### Creating a Store in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/source/v2/recipes/stores.rst This snippet demonstrates how to create a new store entity in Drupal Commerce. It covers setting essential properties such as the store type, owner UID, name, email, address, default currency, and billing countries. It also includes steps to import the currency if needed and to mark the newly created store as the default store for the system. ```php /** * type [String] - [DEFAULT = 'online'] * Foreign key for the store type to yse. * * uid [Integer] * The user id that created the store. * * name [String] * The store's name. * * mail [String] * The store's email address. * * address [\Drupal\address\AddressInterface] * The store's address. * * default_currency [String] * The currency the store uses. * * billing_countries [Array(String)] * Array of country codes selected for the store. */ // The store's address. $address = [ 'country_code' => 'US', 'address_line1' => '123 Street Drive', 'locality' => 'Beverly Hills', 'administrative_area' => 'CA', 'postal_code' => '90210', ]; // The currency code. $currency = 'USD'; // If needed, this will import the currency. $currency_importer = \Drupal::service('commerce_price.currency_importer'); $currency_importer->import($currency); $store = \Drupal\commerce_store\Entity\Store::create([ 'type' => 'custom_store_type', 'uid' => 1, 'name' => 'My Store', 'mail' => 'admin@example.com', 'address' => $address, 'default_currency' => $currency, 'billing_countries' => ['US'], ]); $store->save(); // If needed, this sets the store as the default store. $store_storage = \Drupal::service('entity_type.manager')->getStorage('commerce_store'); $store_storage->markAsDefault($store); ``` -------------------------------- ### Updating Local Git Fork from Upstream Repository (Bash) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/getting-started/contributing/developing.html This sequence updates the local `8.x-2.x` branch by pulling the latest changes from the `origin` (upstream) repository. It then pushes these updates to the developer's GitHub fork, ensuring the fork remains synchronized with the main project. ```Bash # Update your local branch. git checkout 8.x-2.x git pull origin/8.x-2.x # Push the update to your GitHub fork. git push fork 8.x-2.x ``` -------------------------------- ### Creating Products in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/_sources/v2/recipes/products.rst.txt This snippet demonstrates how to create a new product entity in Drupal Commerce. It initializes a `Product` object with a user ID, product type, title, associated stores, and an initial array of variations. After saving the product, it also shows how to add additional variations using the `addVariation()` method, followed by another save operation. ```php /** * uid [Integer] * Foreign key of the user that created the product. * * type [String] - [DEFAULT = default] * Foreign key of the product type being used. * * title [String] * The product title. * * stores [Array(\Drupal\commerce_store\Entity\StoreInterface)] * Array of stores this product belongs to. * * variations [Array(\Drupal\commerce_product\Entity\ProductVariationInterface)] * Array of variations that belong to this product. */ // The variations that belong to this product. $variations = [ $variation_blue_large, ]; $product = \Drupal\commerce_product\Entity\Product::create([ 'uid' => 1, 'type' => 'my_custom_product_type', 'title' => 'My Custom Product', 'stores' => [$store], 'variations' => $variations, ]); $product->save(); // You can also add a variation to a product using the addVariation() method. $product->addVariation($variation_red_medium); $product->save(); ``` -------------------------------- ### Configuring Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/recipes/attributes.html This JavaScript snippet defines global configuration options for the documentation system. It specifies the root URL, version, index collapsing behavior, file suffixes for HTML and source links, and whether source links are enabled. This object is typically consumed by the documentation's front-end scripts to render content correctly. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ``` -------------------------------- ### Creating Products in Drupal Commerce (PHP) Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/recipes/products.html This snippet demonstrates how to programmatically create a new product entity in Drupal Commerce 2.x. It initializes a Product entity with a user ID, product type, title, associated stores, and an initial set of product variations. It also shows how to add additional variations to an existing product using the addVariation() method, followed by saving the product. ```PHP // The variations that belong to this product. $variations = [ $variation_blue_large, ]; $product = \Drupal\commerce_product\Entity\Product::create([ 'uid' => 1, 'type' => 'my_custom_product_type', 'title' => 'My Custom Product', 'stores' => [$store], 'variations' => $variations, ]); $product->save(); // You can also add a variation to a product using the addVariation() method. $product->addVariation($variation_red_medium); $product->save(); ``` -------------------------------- ### Defining Documentation Options in JavaScript Source: https://github.com/qodeone/drupal-commerce/blob/master/docs/build/html/v2/README.html This JavaScript snippet defines a global `DOCUMENTATION_OPTIONS` object, which configures various parameters for the documentation system, such as root URL, version, and file suffixes. It's typically used by Sphinx-generated documentation to manage paths and settings. ```JavaScript var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '0.0.2', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true, SOURCELINK_SUFFIX: '.txt' }; ```