Skip to content

Instantly share code, notes, and snippets.

# The fundamantal design opinion is that a Stock Return has many Returned Items
# Each Returned Item effectively has one of 3 actions associated with it return, exchange OR replace
# Any of these action can involve a refund, although the most common is that a return involves a refund
# You may wish to refund a replacement Or exchange to maintain customer relations
#
# Once all Returned Items and their actions have been set then you can commence to attempt to process the Stock Return
# Processing the Stock Return will automate the Order Adjustments, Addiitonal Shipments and any Refunds / Payments
# It should be exstensible so that developers can easily implement their own behaviour here
#
# It could be that a developer can extend this to Create New Orders instead of Additional Shipments under certain scenarios:
# Shipment
def after_ship
Spree::Config.shipment_handler_class.factory(self).perform
end
module Spree
class ShipmentHandler
class << self
def factory(shipment)
if sm_handler = "Spree::ShipmentHandler::#{shipment.shipping_method.to_s.split('::').last}".constantize rescue false
# MEN'S FLYOUT
mens_new_in:
- {model: Category, id: 12, helper: seo_path}
- {model: Category, id: 13, helper: seo_path}
- {model: Category, id: 14, helper: seo_path}
- {model: Category, id: 15, helper: seo_path}
mens_sale:
- {model: Category, id: 12, helper: seo_path}
<b>NEW IN</b>
<% links('mens_new_in').each do |link| %>
<li><%= link_to(link.anchor, link.href) %></li>
<% end %>
<b>SALE</b>
<% links('mens_sale').each do |link| %>
<li><%= link_to(link.anchor, link.href) %></li>
<% end %>
#https://github.com/spree/spree/blob/master/core/app/models/spree/stock/coordinator.rb#L32:L40
def build_packages(packages = Array.new)
StockLocation.active.each do |stock_location|
next unless stock_location.stock_items.where(:variant_id => inventory_units.map(&:variant_id).uniq).exists?
packer = build_packer(stock_location, inventory_units)
packages += packer.packages
end
packages
class Content < ActiveRecord::Base
end