Skip to content

Instantly share code, notes, and snippets.

View ikraamg's full-sized avatar
🌍
Collaborating

Ikraam Ghoor ikraamg

🌍
Collaborating
View GitHub Profile
@ikraamg
ikraamg / factory_console.rb
Last active January 19, 2023 10:46
How to use factory bot in the console and also receive the errors messages from failed creations
#In rails console:
include FactoryBot::Syntax::Methods
#From: https://github.com/thoughtbot/factory_bot/issues/397#issuecomment-6662051
FactoryBot.define do
to_create do |instance|
unless instance.save
raise "Invalid record: " + instance.errors.messages.to_s
end
diff --git a/core/lib/spree/core/controller_helpers/auth.rb b/core/lib/spree/core/controller_helpers/auth.rb
index 3f21ebb7c6..2112505391 100644
--- a/core/lib/spree/core/controller_helpers/auth.rb
+++ b/core/lib/spree/core/controller_helpers/auth.rb
@@ -54,6 +54,11 @@ module Spree
Spree::UserLastUrlStorer.new(self).store_location
end
+ # Auth extensions are expected to define it, otherwise it's a no-op
+ def spree_current_user
diff --git a/packages/gatsby-starter-autonomy/package.json b/packages/gatsby-starter-autonomy/package.json
index de49216..1e29395 100644
--- a/packages/gatsby-starter-autonomy/package.json
+++ b/packages/gatsby-starter-autonomy/package.json
@@ -16,6 +16,8 @@
"dependencies": {
"@chordcommerce/chord-magic": "^1.0.0",
"@chordcommerce/gatsby-theme-autonomy": "^1.0.0",
+ "@stripe/react-stripe-js": "^1.4.1",
+ "@stripe/stripe-js": "^1.16.0",
{
"sku": "bundle-variant-1",
"quantity": 1,
"options": {
"parts": [
{
"sku": "normal-variant-1",
"quantity": 4
},
{
@ikraamg
ikraamg / line_items_endpoint.sh
Created May 18, 2022 15:25
Dynamic Promotion API example
curl --location --request PUT 'http://localhost:3000/api/orders/CHORD-579656375/line_items/41' \
--header 'X-Spree-Order-Token: QDpqfwxE2eaUr7oo41B6Zw' \
--header 'Content-Type: application/json' \
--data-raw '{
"sku": "product-6",
"quantity": 3,
"dynamic_promotions_attributes": [
{
"code": "existing_code_to_destroy",
"_destroy": 1
@ikraamg
ikraamg / dynamic-promotion.diff
Last active May 18, 2022 15:14
Send dynamic promotions and metadata via addToCart method.
diff --git a/packages/nextjs-starter-autonomy/src/redux/actions/cart/add-to-cart.js b/packages/nextjs-starter-autonomy/src/redux/actions/cart/add-to-cart.js
index e1733c3..eab6c7d 100644
--- a/packages/nextjs-starter-autonomy/src/redux/actions/cart/add-to-cart.js
+++ b/packages/nextjs-starter-autonomy/src/redux/actions/cart/add-to-cart.js
@@ -12,12 +12,18 @@ export const addToCartRequest = sku => {
}
}
-export const addToCartSuccess = (cart, variant, quantity) => {
+export const addToCartSuccess = (
diff --git a/package.json b/package.json
index 4b6438c..55622ef 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"@stripe/terminal-js": "^0.9.0",
"babel-plugin-styled-components": "^1.10.7",
"copy-to-clipboard": "^3.3.1",
+ "date-fns": "^2.28.0",
"dotenv": "^10.0.0",
@ikraamg
ikraamg / cross-sell-body.json
Last active May 6, 2022 13:57
Post checkout cross sell example POST body
{
"order": {
"line_items_attributes": [
{
"sku": "product-1",
"quantity": 2,
"subscription_line_items_attributes": [
{
"interval_length": 3,
"interval_units": "month"
@ikraamg
ikraamg / post-checkout-email.mustache
Created May 6, 2022 10:42
Post checkout cross sell email
<wrapper class="header">
<container>
<row>
<columns>
<h3 class="text-center"> Hey {{ship_address.firstname}}, </h3>
<p class="text-center"> We've updated your order to include your recently purchased items. </p>
</columns>
</row>
</container>
</wrapper>
diff --git a/graphql-cms/queries/catalog.js b/graphql-cms/queries/catalog.js
index 75d1f9d..db89a42 100644
--- a/graphql-cms/queries/catalog.js
+++ b/graphql-cms/queries/catalog.js
@@ -1,6 +1,7 @@
import { fetchGraphQL } from '../api'
import { COLLECTION_FRAGMENT } from 'graphql-cms/fragments'
import placeholder from 'graphql-cms/utils/placeholder'
+import { bootstrapReduxStore } from './redux'