Giter Club home page Giter Club logo

solidus_price_modifier's Introduction

SolidusPriceModifier

Build Status

This extension extracts a deprecated pricing hack from Solidus core. It consists of freedom patches on both Spree::Variant and Spree::LineItem, which your app should implement.

The orginal extension point allowed for any freedom patch, while this extension only allows the most common one: Gift wrapping. Here's what your app has to do for this extension to work:

Spree::Variant

Provide a method that specifies the Gift wrap price modifier amount for different currencies. For example:

Spree::Variant.class_eval do
  def gift_wrap_price_modifier_amount_in(_currency, value)
    value ? 2 : 0 # Two whatever currency added for gift wrapping
  end
end

Spree::LineItem

Provide a persisted something on the line item to hold whether it is to gift wrapped or not. You will probably have done this by adding a column to the line item, which would make some sense. Here's a pure Ruby implementation:

Spree::LineItem.class_eval do
  attr_accessor :gift_wrap
end

Configure your app accordingly

Spree.config do |config|
  config.variant_pricer_class = Spree::Variant::GiftWrapPricer
end

If you need other price modifiers, like maybe unbranded carton, you need to write your own Pricer, and you have to change the method names in the freedom patches on Spree::LineItem and Spree::Variant Spree::LineItem#unbranded_carton / Spree::Variant#unbranded_carton_price_modifier_amount_in.

If you're actually using this, consider moving to a more sustainable approach. This extension will have support only for Solidus ~> 1.3. This extension is meant to ease your transition to better pricing solutions.

Installation

Add solidus_price_modifier to your Gemfile:

gem 'solidus_price_modifier'

Bundle your dependencies and run the installation generator:

bundle
bundle exec rails g solidus_price_modifier:install

Testing

First bundle your dependencies, then run rake. rake will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using rake test_app.

bundle
bundle exec rake

Copyright (c) 2016 [Stembolt], released under the New BSD License

solidus_price_modifier's People

Contributors

mamhoff avatar

Watchers

Patrick Sinclair avatar Tal Oron avatar Tom Cartwright avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.