django-Oscar








Hocking $H*T ON THe internet is easy right?




So why another e-commerce platform?

Let me tell you a story


Once upon a time...


Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah PHP blah blah blah many suppliers blah blah blah books blah blah blah blah blah blah blah 20M+ SKUs blah blah blah blah Pay Pal urgh blah blah blah blah credit cards blah blah blah blah loyalty blah blah blah blah blah blah blah offers blah blah blah blah blah blah. And oh yeah, you got ~3 months. Blah blah blah blah blah blah blah blah.

Later that decade...


Plenty of "e-commerce" experience.

  • Features: MOAR!
  • Products: MOAR!
  • Integrations: MOAR!
  • Complexity: MOAR! 



Me == :-(


Time for a rethink...


We saw the light!*











* or more precisely @codeinthehole did


"Oscar was built from the ground up to make very few assumptions about your project, allowing virtually any part of the framework to be extended and customised. In this way, complex business rules can be captured in an elegant and cohesive way."

So what does that actually mean?


    • Abstract models for everything*
    • We expect you to add stuff
    • We expect you to extend stuff
    • We know you will do unexpected thing
    • We know your clients will ask for weird things

Everything is written with the assumption that your next project will require something no-one has thought of yet.

* almost ™

extend


# yourproject/catalogue/models.py

from django.db import models

from oscar.apps.catalogue.abstract_models import AbstractProduct

class Product(AbstractProduct):
    video_url = models.URLField()

from oscar.apps.catalogue.models import *

Don't forget to add 'yourproject.catalogue' to INSTALLED_APPS

OVERRIDE

# yourproject/order/utils.py

from oscar.apps.order.utils import OrderNumberGenerator as CoreOrderNumberGenerator


class OrderNumberGenerator(CoreOrderNumberGenerator):

    def order_number(self, basket=None):
        num = super(OrderNumberGenerator, self).order_number(basket)
        return "SHOP-%s" % num
You can double check this is actually working with:
>>> from oscar.core.loading import get_class
>>> get_class('order.utils', 'OrderNumberGenerator')


And for those front-enders..

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
)

import os
location = lambda x: os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', x)
from oscar import OSCAR_MAIN_TEMPLATE_DIR
TEMPLATE_DIRS = (
    location('templates'),
    OSCAR_MAIN_TEMPLATE_DIR,
)
Then in your templates:
# base.html
{% extends 'oscar/base.html' %}

...

You want MOAR!

How about some custom offers?
from oscar.apps.offer import models

class BasketOwnerCalledBarry(models.Condition):
    name = "User must be called barry"

    class Meta:
        proxy = True

    def is_satisfied(self, basket):
        if not basket.owner:
            return False
        return basket.owner.first_name.lower() == 'barry'
from oscar.apps.offer.custom import create_condition

create_condition(BasketOwnerCalledBarry)

Availability & Pricing

  • Not tied to the product model
  • Uses the 'strategy' pattern*
  • Allows for really flexible pricing and tax handling
    • Dynamic stock allocation
    • Dynamic pricing
    • Deferred application of tax (e.g. for the US)
    • Partner specific availability rules



* or there abouts

TaxES

# yourproject/parnter/strategy.py

from oscar.apps.parnter import strategy


class IncludingVAT(strategy.FixedRateTax):

    rate = D('0.15')
class AUStrategy(strategy.UseFirstStockRecord, IncludingVAT,
                 strategy.StockRequired, strategy.Structured):

    pass

You'll still need to let Oscar know where to load the strategy from.

and more...



multi-lingual, flexible offers, extensible dashboard, wishlists, multiple-stock records, reviews, @elbaschid, product attributes, product variants, django, payment options, lesscss, extension apps, not written by me, analytics, bootstrap, @codeinthehole, supplier availability rules, shipping options, django, vouchers, test coverage, custom user model, fine-grained dashboard permissions.
Commits: 
Oscar -Next -

Tangent Written APPs


  • django-oscar-paypal
  • django-oscar-datacash
  • django-oscar-account
  • django-oscar-eway
  • django-oscar-easyrec*
  • django-oscar-fancypages*
  • etc...

* I made this
* @elbaschid may admit to this

Community Additions


  • django-oscar-unicredits
  • django-oscar-payments
  • django-oscar-erp
  • django-oscar-recurly
  • etc...




TASTY?

See more...




Thanks for listening!
Feel free to grab me, Francis or Sebastian if you want talk some more.

django-oscar

By Jonathan Moss

django-oscar

  • 1,046