class ICoupon(model.Schema):

    code = schema.TextLine(title=u'Code', )

    categories = schema.Set(
        title=u'Product Category',
        description=u'If specified, this coupon will only apply to '
        u'products from the specified categories.',
        value_type=schema.Choice(
            vocabulary='jazkarta.shop.product_categories', ),
    )

    scope = schema.Choice(
        title=u'Discount applies to',
        values=(
            u'One item',
            u'All items in cart',
        ),
    )

    amount = Currency(title=u'Discount Amount', )

    unit = schema.Choice(
        title=u'Discount Unit',
        values=(u'$', u'%'),
    )

    per_user_limit = schema.Int(
        title=u'Use Limit Per User',
        description=u'The number of times this coupon may be used '
        u'by an individual. Enter 0 for unlimited.',
        default=1,
    )

    product = schema.Choice(
        title=u'Specific Product',
        description=u'Optionally specify one product to which this coupon '
        u'may be applied.',
        source=CatalogSource(
            object_provides='jazkarta.shop.interfaces.IProduct'),
        required=False,
    )

    # excluded_products = schema.Set(
    #     title=u'Excluded Products',
    #     description=u'Products for which this coupon may not be used.',
    #     value_type=schema.Choice(
    #         source=CatalogSource(
    #             object_provides='jazkarta.shop.interfaces.IProduct'),
    #     ),
    #     required=False,
    # )

    start = schema.Datetime(title=u'Start Date', )

    end = schema.Datetime(title=u'End Date', )
Example #2
0
class IProduct(model.Schema):
    """Marker for content that can be purchased."""

    product_category = schema.Choice(
        title=u'Product Category',
        required=False,
        vocabulary='jazkarta.shop.product_categories',
    )

    price = Currency(
        title=u'Unit Price',
        default=Decimal("0.00"),
        min=Decimal("0.00"),
    )

    stock_level = schema.Int(
        title=u'Stock Level',
        description=u'Number of items remaining in warehouse. '
        u'Leave blank for no limit.',
        required=False,
        min=0,
    )

    taxable = schema.Bool(
        title=u'Taxable?',
        description=u'Mark the box if this product is subject to sales tax.',
        default=True,
    )

    weight = schema.Float(
        title=u'Weight (lbs)',
        description=u'Used to calculate shipping.',
        required=False,
    )

    recommended_products = RelationList(
        title=u'Recommended products',
        description=
        u'Recommendations to users who bought this product, shown during checkout.',
        default=[],
        required=False,
        value_type=schema.Choice(source=CatalogSource(
            object_provides='jazkarta.shop.interfaces.IProduct'), ))

    model.fieldset(
        'shop',
        label=u"Shop",
        fields=(
            'product_category',
            'price',
            'stock_level',
            'taxable',
            'weight',
            'recommended_products',
        ),
    )
class IProduct(model.Schema):
    """Marker for content that can be purchased."""

    product_category = schema.Choice(
        title=u'Product Category',
        required=False,
        vocabulary='jazkarta.shop.product_categories',
    )

    price = Currency(
        title=u'Unit Price',
        default=Decimal("0.00"),
        min=Decimal("0.00"),
    )

    stock_level = schema.Int(
        title=u'Stock Level',
        description=u'Number of items remaining in warehouse. '
        u'Leave blank for no limit.',
        required=False,
        min=0,
    )

    taxable = schema.Bool(
        title=u'Taxable?',
        description=u'Mark the box if this product is subject to sales tax.',
        default=True,
    )

    weight = schema.Float(
        title=u'Weight (lbs)',
        description=u'Used to calculate shipping.',
        required=False,
    )

    model.fieldset(
        'shop',
        label=u"Shop",
        fields=(
            'product_category',
            'price',
            'stock_level',
            'taxable',
            'weight',
        ),
    )
class IWeightPrice(model.Schema):
    min = schema.Float(
        title=u'Min Weight',
        required=False,
    )
    form.widget('min', size=4)
    max = schema.Float(
        title=u'Max Weight',
        required=False,
    )
    form.widget('max', size=4)
    rate = Currency(
        title=u'Rate',
        required=False,
    )
    form.widget('rate', size=4)
    is_percent = schema.Bool(
        title=u'Percent',
        default=False,
    )
class IShippingMethod(model.Schema):
    name = schema.TextLine(title=u'Name')
    zones = schema.Set(
        title=u'Zones',
        description=u'Where is this shipping method available?',
        value_type=schema.Choice(
            vocabulary=SimpleVocabulary.fromValues(config.SHIPPING_ZONES)),
    )
    form.widget('zones', CheckBoxWidget)
    min_purchase = Currency(
        title=u'Minimum Purchase',
        description=u'If specified, this shipping method will only be '
        u'available for orders with a subtotal greater than this '
        u'value.',
        required=False,
    )
    form.widget('min_purchase', size=3)
    calculation = schema.Choice(
        title=u'Calculation Method',
        vocabulary=CALCULATION_METHODS,
    )
    weight_table = schema.List(title=u'Shipping Fee by Weight',
                               value_type=DictRow(schema=IWeightPrice))
    form.widget('weight_table', DataGridFieldFactory)