Django-Oscar Basket customization

Multi tool use
Multi tool use












4














I am using Djnago-oscar for Solar energy equipment based eCommerce site. I need to add an option to "Basket" model with "Battery Name", "Notes" and
"Manufacturer". There is a reason I don't want to add it in subclass AbstractProduct. Rather I want to built it with subclass Basket model.
Now I need help to understand my workflow to make this work with AddToBasket form. In Django-oscar/basket there are formsets.py using formset factory and a form.
I am a bit confused and decided to get help from community.



Following is the code:



models.py



MANUFACTURERS = (
('UPS SYSTEMS', 'UPS SYSTEMS'),
('VOLTA', 'VOLTA'),
('TOSHIBA ', 'TOSHIBA '),
)

BATTERIES = (
('LITHIUM', 'LITHIUM'),
('NICAD', 'NICAD'),
('NIFE ', 'NIFE '),
)

class AddBattery(AbstractBasket):
battery_name = models.CharField(max_length=1, choices=BATTERIES)
manufacturers = models.CharField(max_length=1, choices=MANUFACTURERS)
price = models.DecimalField(decimal_places=2, max_digits=6)
notes = models.CharField(max_length=200, null=True, blank=True)

def __str__(self):
return self.battery_name


class Basket(AbstractBasket):
add_bat=models.ForeignKey(_(u'Add a Batter'), to=AddBattery, null=True, blank=True)


forms.py



from django import forms
from django.conf import settings
from django.db.models import Sum
from django.utils.translation import ugettext_lazy as _

from oscar.forms import widgets
from oscar.apps.basket.forms import BasketLineForm as CoreBasketLineForm,
SavedLineForm as CoreSavedLineForm, BasketVoucherForm as CoreBasketVoucherForm,
AddToBasketForm as CoreAddToBasketForm

from .models import AddBattery
from oscar.core.loading import get_model, get_classes

Line = get_model('basket', 'line')
Basket = get_model('basket', 'basket')
Product = get_model('catalogue', 'product')



class BasketLineForm(CoreBasketLineForm):
class AddBatteryForm(CoreBasketLineForm.Meta):
model = AddBattery
fields = ['battery_name', 'manufacturers', 'comment']


views.py



I need help to figure this part because it has so much nested elements and I couldn't get it right.
Help is much appreciated.



Templates:
I can work this out because I need admin to have ability to add it but end user only will have an option to select from with price.
Upon selection by client I need to have consolidated price with products and plus the battery. Any advise for this part would be great as well
about how to get consolidated price from both in cart for checkout.










share|improve this question



























    4














    I am using Djnago-oscar for Solar energy equipment based eCommerce site. I need to add an option to "Basket" model with "Battery Name", "Notes" and
    "Manufacturer". There is a reason I don't want to add it in subclass AbstractProduct. Rather I want to built it with subclass Basket model.
    Now I need help to understand my workflow to make this work with AddToBasket form. In Django-oscar/basket there are formsets.py using formset factory and a form.
    I am a bit confused and decided to get help from community.



    Following is the code:



    models.py



    MANUFACTURERS = (
    ('UPS SYSTEMS', 'UPS SYSTEMS'),
    ('VOLTA', 'VOLTA'),
    ('TOSHIBA ', 'TOSHIBA '),
    )

    BATTERIES = (
    ('LITHIUM', 'LITHIUM'),
    ('NICAD', 'NICAD'),
    ('NIFE ', 'NIFE '),
    )

    class AddBattery(AbstractBasket):
    battery_name = models.CharField(max_length=1, choices=BATTERIES)
    manufacturers = models.CharField(max_length=1, choices=MANUFACTURERS)
    price = models.DecimalField(decimal_places=2, max_digits=6)
    notes = models.CharField(max_length=200, null=True, blank=True)

    def __str__(self):
    return self.battery_name


    class Basket(AbstractBasket):
    add_bat=models.ForeignKey(_(u'Add a Batter'), to=AddBattery, null=True, blank=True)


    forms.py



    from django import forms
    from django.conf import settings
    from django.db.models import Sum
    from django.utils.translation import ugettext_lazy as _

    from oscar.forms import widgets
    from oscar.apps.basket.forms import BasketLineForm as CoreBasketLineForm,
    SavedLineForm as CoreSavedLineForm, BasketVoucherForm as CoreBasketVoucherForm,
    AddToBasketForm as CoreAddToBasketForm

    from .models import AddBattery
    from oscar.core.loading import get_model, get_classes

    Line = get_model('basket', 'line')
    Basket = get_model('basket', 'basket')
    Product = get_model('catalogue', 'product')



    class BasketLineForm(CoreBasketLineForm):
    class AddBatteryForm(CoreBasketLineForm.Meta):
    model = AddBattery
    fields = ['battery_name', 'manufacturers', 'comment']


    views.py



    I need help to figure this part because it has so much nested elements and I couldn't get it right.
    Help is much appreciated.



    Templates:
    I can work this out because I need admin to have ability to add it but end user only will have an option to select from with price.
    Upon selection by client I need to have consolidated price with products and plus the battery. Any advise for this part would be great as well
    about how to get consolidated price from both in cart for checkout.










    share|improve this question

























      4












      4








      4


      1





      I am using Djnago-oscar for Solar energy equipment based eCommerce site. I need to add an option to "Basket" model with "Battery Name", "Notes" and
      "Manufacturer". There is a reason I don't want to add it in subclass AbstractProduct. Rather I want to built it with subclass Basket model.
      Now I need help to understand my workflow to make this work with AddToBasket form. In Django-oscar/basket there are formsets.py using formset factory and a form.
      I am a bit confused and decided to get help from community.



      Following is the code:



      models.py



      MANUFACTURERS = (
      ('UPS SYSTEMS', 'UPS SYSTEMS'),
      ('VOLTA', 'VOLTA'),
      ('TOSHIBA ', 'TOSHIBA '),
      )

      BATTERIES = (
      ('LITHIUM', 'LITHIUM'),
      ('NICAD', 'NICAD'),
      ('NIFE ', 'NIFE '),
      )

      class AddBattery(AbstractBasket):
      battery_name = models.CharField(max_length=1, choices=BATTERIES)
      manufacturers = models.CharField(max_length=1, choices=MANUFACTURERS)
      price = models.DecimalField(decimal_places=2, max_digits=6)
      notes = models.CharField(max_length=200, null=True, blank=True)

      def __str__(self):
      return self.battery_name


      class Basket(AbstractBasket):
      add_bat=models.ForeignKey(_(u'Add a Batter'), to=AddBattery, null=True, blank=True)


      forms.py



      from django import forms
      from django.conf import settings
      from django.db.models import Sum
      from django.utils.translation import ugettext_lazy as _

      from oscar.forms import widgets
      from oscar.apps.basket.forms import BasketLineForm as CoreBasketLineForm,
      SavedLineForm as CoreSavedLineForm, BasketVoucherForm as CoreBasketVoucherForm,
      AddToBasketForm as CoreAddToBasketForm

      from .models import AddBattery
      from oscar.core.loading import get_model, get_classes

      Line = get_model('basket', 'line')
      Basket = get_model('basket', 'basket')
      Product = get_model('catalogue', 'product')



      class BasketLineForm(CoreBasketLineForm):
      class AddBatteryForm(CoreBasketLineForm.Meta):
      model = AddBattery
      fields = ['battery_name', 'manufacturers', 'comment']


      views.py



      I need help to figure this part because it has so much nested elements and I couldn't get it right.
      Help is much appreciated.



      Templates:
      I can work this out because I need admin to have ability to add it but end user only will have an option to select from with price.
      Upon selection by client I need to have consolidated price with products and plus the battery. Any advise for this part would be great as well
      about how to get consolidated price from both in cart for checkout.










      share|improve this question













      I am using Djnago-oscar for Solar energy equipment based eCommerce site. I need to add an option to "Basket" model with "Battery Name", "Notes" and
      "Manufacturer". There is a reason I don't want to add it in subclass AbstractProduct. Rather I want to built it with subclass Basket model.
      Now I need help to understand my workflow to make this work with AddToBasket form. In Django-oscar/basket there are formsets.py using formset factory and a form.
      I am a bit confused and decided to get help from community.



      Following is the code:



      models.py



      MANUFACTURERS = (
      ('UPS SYSTEMS', 'UPS SYSTEMS'),
      ('VOLTA', 'VOLTA'),
      ('TOSHIBA ', 'TOSHIBA '),
      )

      BATTERIES = (
      ('LITHIUM', 'LITHIUM'),
      ('NICAD', 'NICAD'),
      ('NIFE ', 'NIFE '),
      )

      class AddBattery(AbstractBasket):
      battery_name = models.CharField(max_length=1, choices=BATTERIES)
      manufacturers = models.CharField(max_length=1, choices=MANUFACTURERS)
      price = models.DecimalField(decimal_places=2, max_digits=6)
      notes = models.CharField(max_length=200, null=True, blank=True)

      def __str__(self):
      return self.battery_name


      class Basket(AbstractBasket):
      add_bat=models.ForeignKey(_(u'Add a Batter'), to=AddBattery, null=True, blank=True)


      forms.py



      from django import forms
      from django.conf import settings
      from django.db.models import Sum
      from django.utils.translation import ugettext_lazy as _

      from oscar.forms import widgets
      from oscar.apps.basket.forms import BasketLineForm as CoreBasketLineForm,
      SavedLineForm as CoreSavedLineForm, BasketVoucherForm as CoreBasketVoucherForm,
      AddToBasketForm as CoreAddToBasketForm

      from .models import AddBattery
      from oscar.core.loading import get_model, get_classes

      Line = get_model('basket', 'line')
      Basket = get_model('basket', 'basket')
      Product = get_model('catalogue', 'product')



      class BasketLineForm(CoreBasketLineForm):
      class AddBatteryForm(CoreBasketLineForm.Meta):
      model = AddBattery
      fields = ['battery_name', 'manufacturers', 'comment']


      views.py



      I need help to figure this part because it has so much nested elements and I couldn't get it right.
      Help is much appreciated.



      Templates:
      I can work this out because I need admin to have ability to add it but end user only will have an option to select from with price.
      Upon selection by client I need to have consolidated price with products and plus the battery. Any advise for this part would be great as well
      about how to get consolidated price from both in cart for checkout.







      django-forms django-oscar django-formwizard






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 30 '18 at 12:23









      Shazia Nusrat

      210323




      210323
























          2 Answers
          2






          active

          oldest

          votes


















          3





          +200










          1. Don't add your fields in Basket model. You need to subclass Line model instead.

          2. Subclass forms.py and formsets.py. You only need to change BasketLineForm, SavedLineForm and AddBasketForm. After you subclass these in your own forms. Leave rest of the Forms.

          3. Subclass BaseBasketLineFormSet and BaseSavedLineFormSet in your own formsets edit as per your need.

          4. Subclass BasketView and AddBasketView by supplying the forms, formsets and args/kwargs you added.

          5. Copy template directory from app to your own folder and add form at basket_total.html as you mentioned above as the last part.


          But having said that...its against the workflow as explained by others. There is no limitation at all for you in any case as far as programming is concerned. But you should always consider the most reasonable path to solve your problems.






          share|improve this answer























          • Why not to add it in Basket? Is there some sense to it?
            – Shazia Nusrat
            Dec 7 '18 at 14:41










          • Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
            – Mudassar Hashmi
            Dec 7 '18 at 14:42










          • Makes sense. I will definitely try this and will update you if I got questions. Thanks.
            – Shazia Nusrat
            Dec 7 '18 at 14:45










          • Thank you so much. It worked :-)
            – Shazia Nusrat
            Dec 7 '18 at 17:38



















          1














          This is a very broad question with several different components. I can offer the following suggestions for you to look into:




          1. Doing this in the basket model is almost certainly not going to serve you well, because you will not be able to pass this custom information to the order object when it is created. More importantly, what you're trying to do doesn't seem to be a basket issue, just a product/variant issue (see below).



          2. There are two possibilities I can see from what you have described:



            a. A battery is a separate product that the user buys along with the main product. It has its own pricing and availability.



            b. A battery isn't a separate product, it's just one of a fixed set of choices that a customer has when buying the main product.




          If (a), then you just need to have separate products, and some logic that allows a user to select the accessory product (battery) at the same time as the main one, and that adds both to the basket simultaneously.



          If (b), then these are essentially variants where one product has multiple variations with different pricing. In this case you should use Oscar's built-in support for variants.



          In any case, modifying the basket model will cause you a lot of problems IMO.






          share|improve this answer





















          • Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
            – Shazia Nusrat
            Dec 1 '18 at 14:13






          • 1




            Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
            – solarissmoke
            Dec 3 '18 at 5:08










          • I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
            – Shazia Nusrat
            Dec 3 '18 at 8:45










          • @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
            – shad0w_wa1k3r
            Dec 5 '18 at 19:25











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53557546%2fdjango-oscar-basket-customization%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3





          +200










          1. Don't add your fields in Basket model. You need to subclass Line model instead.

          2. Subclass forms.py and formsets.py. You only need to change BasketLineForm, SavedLineForm and AddBasketForm. After you subclass these in your own forms. Leave rest of the Forms.

          3. Subclass BaseBasketLineFormSet and BaseSavedLineFormSet in your own formsets edit as per your need.

          4. Subclass BasketView and AddBasketView by supplying the forms, formsets and args/kwargs you added.

          5. Copy template directory from app to your own folder and add form at basket_total.html as you mentioned above as the last part.


          But having said that...its against the workflow as explained by others. There is no limitation at all for you in any case as far as programming is concerned. But you should always consider the most reasonable path to solve your problems.






          share|improve this answer























          • Why not to add it in Basket? Is there some sense to it?
            – Shazia Nusrat
            Dec 7 '18 at 14:41










          • Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
            – Mudassar Hashmi
            Dec 7 '18 at 14:42










          • Makes sense. I will definitely try this and will update you if I got questions. Thanks.
            – Shazia Nusrat
            Dec 7 '18 at 14:45










          • Thank you so much. It worked :-)
            – Shazia Nusrat
            Dec 7 '18 at 17:38
















          3





          +200










          1. Don't add your fields in Basket model. You need to subclass Line model instead.

          2. Subclass forms.py and formsets.py. You only need to change BasketLineForm, SavedLineForm and AddBasketForm. After you subclass these in your own forms. Leave rest of the Forms.

          3. Subclass BaseBasketLineFormSet and BaseSavedLineFormSet in your own formsets edit as per your need.

          4. Subclass BasketView and AddBasketView by supplying the forms, formsets and args/kwargs you added.

          5. Copy template directory from app to your own folder and add form at basket_total.html as you mentioned above as the last part.


          But having said that...its against the workflow as explained by others. There is no limitation at all for you in any case as far as programming is concerned. But you should always consider the most reasonable path to solve your problems.






          share|improve this answer























          • Why not to add it in Basket? Is there some sense to it?
            – Shazia Nusrat
            Dec 7 '18 at 14:41










          • Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
            – Mudassar Hashmi
            Dec 7 '18 at 14:42










          • Makes sense. I will definitely try this and will update you if I got questions. Thanks.
            – Shazia Nusrat
            Dec 7 '18 at 14:45










          • Thank you so much. It worked :-)
            – Shazia Nusrat
            Dec 7 '18 at 17:38














          3





          +200







          3





          +200



          3




          +200





          1. Don't add your fields in Basket model. You need to subclass Line model instead.

          2. Subclass forms.py and formsets.py. You only need to change BasketLineForm, SavedLineForm and AddBasketForm. After you subclass these in your own forms. Leave rest of the Forms.

          3. Subclass BaseBasketLineFormSet and BaseSavedLineFormSet in your own formsets edit as per your need.

          4. Subclass BasketView and AddBasketView by supplying the forms, formsets and args/kwargs you added.

          5. Copy template directory from app to your own folder and add form at basket_total.html as you mentioned above as the last part.


          But having said that...its against the workflow as explained by others. There is no limitation at all for you in any case as far as programming is concerned. But you should always consider the most reasonable path to solve your problems.






          share|improve this answer















          1. Don't add your fields in Basket model. You need to subclass Line model instead.

          2. Subclass forms.py and formsets.py. You only need to change BasketLineForm, SavedLineForm and AddBasketForm. After you subclass these in your own forms. Leave rest of the Forms.

          3. Subclass BaseBasketLineFormSet and BaseSavedLineFormSet in your own formsets edit as per your need.

          4. Subclass BasketView and AddBasketView by supplying the forms, formsets and args/kwargs you added.

          5. Copy template directory from app to your own folder and add form at basket_total.html as you mentioned above as the last part.


          But having said that...its against the workflow as explained by others. There is no limitation at all for you in any case as far as programming is concerned. But you should always consider the most reasonable path to solve your problems.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Dec 28 '18 at 3:09









          pelekoudasq

          75




          75










          answered Dec 7 '18 at 14:34









          Mudassar Hashmi

          1,2761019




          1,2761019












          • Why not to add it in Basket? Is there some sense to it?
            – Shazia Nusrat
            Dec 7 '18 at 14:41










          • Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
            – Mudassar Hashmi
            Dec 7 '18 at 14:42










          • Makes sense. I will definitely try this and will update you if I got questions. Thanks.
            – Shazia Nusrat
            Dec 7 '18 at 14:45










          • Thank you so much. It worked :-)
            – Shazia Nusrat
            Dec 7 '18 at 17:38


















          • Why not to add it in Basket? Is there some sense to it?
            – Shazia Nusrat
            Dec 7 '18 at 14:41










          • Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
            – Mudassar Hashmi
            Dec 7 '18 at 14:42










          • Makes sense. I will definitely try this and will update you if I got questions. Thanks.
            – Shazia Nusrat
            Dec 7 '18 at 14:45










          • Thank you so much. It worked :-)
            – Shazia Nusrat
            Dec 7 '18 at 17:38
















          Why not to add it in Basket? Is there some sense to it?
          – Shazia Nusrat
          Dec 7 '18 at 14:41




          Why not to add it in Basket? Is there some sense to it?
          – Shazia Nusrat
          Dec 7 '18 at 14:41












          Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
          – Mudassar Hashmi
          Dec 7 '18 at 14:42




          Basket is locked with Line added to it. Line includes all the product related attributes/features etc. Adding new fields to basket means you will have to redo the whole structure of Basket. Rest is up to you to decide. This is closest to what you want. Instead use solution by built-in Oscar's features.
          – Mudassar Hashmi
          Dec 7 '18 at 14:42












          Makes sense. I will definitely try this and will update you if I got questions. Thanks.
          – Shazia Nusrat
          Dec 7 '18 at 14:45




          Makes sense. I will definitely try this and will update you if I got questions. Thanks.
          – Shazia Nusrat
          Dec 7 '18 at 14:45












          Thank you so much. It worked :-)
          – Shazia Nusrat
          Dec 7 '18 at 17:38




          Thank you so much. It worked :-)
          – Shazia Nusrat
          Dec 7 '18 at 17:38













          1














          This is a very broad question with several different components. I can offer the following suggestions for you to look into:




          1. Doing this in the basket model is almost certainly not going to serve you well, because you will not be able to pass this custom information to the order object when it is created. More importantly, what you're trying to do doesn't seem to be a basket issue, just a product/variant issue (see below).



          2. There are two possibilities I can see from what you have described:



            a. A battery is a separate product that the user buys along with the main product. It has its own pricing and availability.



            b. A battery isn't a separate product, it's just one of a fixed set of choices that a customer has when buying the main product.




          If (a), then you just need to have separate products, and some logic that allows a user to select the accessory product (battery) at the same time as the main one, and that adds both to the basket simultaneously.



          If (b), then these are essentially variants where one product has multiple variations with different pricing. In this case you should use Oscar's built-in support for variants.



          In any case, modifying the basket model will cause you a lot of problems IMO.






          share|improve this answer





















          • Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
            – Shazia Nusrat
            Dec 1 '18 at 14:13






          • 1




            Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
            – solarissmoke
            Dec 3 '18 at 5:08










          • I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
            – Shazia Nusrat
            Dec 3 '18 at 8:45










          • @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
            – shad0w_wa1k3r
            Dec 5 '18 at 19:25
















          1














          This is a very broad question with several different components. I can offer the following suggestions for you to look into:




          1. Doing this in the basket model is almost certainly not going to serve you well, because you will not be able to pass this custom information to the order object when it is created. More importantly, what you're trying to do doesn't seem to be a basket issue, just a product/variant issue (see below).



          2. There are two possibilities I can see from what you have described:



            a. A battery is a separate product that the user buys along with the main product. It has its own pricing and availability.



            b. A battery isn't a separate product, it's just one of a fixed set of choices that a customer has when buying the main product.




          If (a), then you just need to have separate products, and some logic that allows a user to select the accessory product (battery) at the same time as the main one, and that adds both to the basket simultaneously.



          If (b), then these are essentially variants where one product has multiple variations with different pricing. In this case you should use Oscar's built-in support for variants.



          In any case, modifying the basket model will cause you a lot of problems IMO.






          share|improve this answer





















          • Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
            – Shazia Nusrat
            Dec 1 '18 at 14:13






          • 1




            Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
            – solarissmoke
            Dec 3 '18 at 5:08










          • I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
            – Shazia Nusrat
            Dec 3 '18 at 8:45










          • @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
            – shad0w_wa1k3r
            Dec 5 '18 at 19:25














          1












          1








          1






          This is a very broad question with several different components. I can offer the following suggestions for you to look into:




          1. Doing this in the basket model is almost certainly not going to serve you well, because you will not be able to pass this custom information to the order object when it is created. More importantly, what you're trying to do doesn't seem to be a basket issue, just a product/variant issue (see below).



          2. There are two possibilities I can see from what you have described:



            a. A battery is a separate product that the user buys along with the main product. It has its own pricing and availability.



            b. A battery isn't a separate product, it's just one of a fixed set of choices that a customer has when buying the main product.




          If (a), then you just need to have separate products, and some logic that allows a user to select the accessory product (battery) at the same time as the main one, and that adds both to the basket simultaneously.



          If (b), then these are essentially variants where one product has multiple variations with different pricing. In this case you should use Oscar's built-in support for variants.



          In any case, modifying the basket model will cause you a lot of problems IMO.






          share|improve this answer












          This is a very broad question with several different components. I can offer the following suggestions for you to look into:




          1. Doing this in the basket model is almost certainly not going to serve you well, because you will not be able to pass this custom information to the order object when it is created. More importantly, what you're trying to do doesn't seem to be a basket issue, just a product/variant issue (see below).



          2. There are two possibilities I can see from what you have described:



            a. A battery is a separate product that the user buys along with the main product. It has its own pricing and availability.



            b. A battery isn't a separate product, it's just one of a fixed set of choices that a customer has when buying the main product.




          If (a), then you just need to have separate products, and some logic that allows a user to select the accessory product (battery) at the same time as the main one, and that adds both to the basket simultaneously.



          If (b), then these are essentially variants where one product has multiple variations with different pricing. In this case you should use Oscar's built-in support for variants.



          In any case, modifying the basket model will cause you a lot of problems IMO.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 1 '18 at 3:39









          solarissmoke

          15.3k83341




          15.3k83341












          • Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
            – Shazia Nusrat
            Dec 1 '18 at 14:13






          • 1




            Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
            – solarissmoke
            Dec 3 '18 at 5:08










          • I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
            – Shazia Nusrat
            Dec 3 '18 at 8:45










          • @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
            – shad0w_wa1k3r
            Dec 5 '18 at 19:25


















          • Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
            – Shazia Nusrat
            Dec 1 '18 at 14:13






          • 1




            Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
            – solarissmoke
            Dec 3 '18 at 5:08










          • I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
            – Shazia Nusrat
            Dec 3 '18 at 8:45










          • @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
            – shad0w_wa1k3r
            Dec 5 '18 at 19:25
















          Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
          – Shazia Nusrat
          Dec 1 '18 at 14:13




          Can you please still update the answer with Workflow that at least should explain the map of inherited view. I will deal with problems if there are any. I would be really thankful to you.
          – Shazia Nusrat
          Dec 1 '18 at 14:13




          1




          1




          Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
          – solarissmoke
          Dec 3 '18 at 5:08




          Not really, because you first need to decide which approach makes most sense for you - I described two possible ones above. If you use variants then there is very little to do because these are support out of the box.
          – solarissmoke
          Dec 3 '18 at 5:08












          I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
          – Shazia Nusrat
          Dec 3 '18 at 8:45




          I want to go with option 1 certainly because I guess with this I will really be able to solve a lot of Django-Oscar issues I have with no more help.
          – Shazia Nusrat
          Dec 3 '18 at 8:45












          @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
          – shad0w_wa1k3r
          Dec 5 '18 at 19:25




          @ShaziaNusrat Going with a variant would be much simpler like solarissmoke pointed out. Oscar has built-in support for that, otherwise (option 1) there will be a lot of workarounds which may cause other bugs / headaches down the line.
          – shad0w_wa1k3r
          Dec 5 '18 at 19:25


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53557546%2fdjango-oscar-basket-customization%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          is vzSHTZ9A8gRqvg4,my4BzHZ31dh8btzFw6P DVOZbLFRCAm N
          f fO7Ts8uPpQuTvWqvPa53,S nyxCD9,IE CpJo6Mln,Bw9 zT1ya 0llXejwgn,oytwSR0dJsNh oLNl1 z84po lY

          Popular posts from this blog

          Monofisismo

          compose and upload a new article using a custom form

          “attempting to read past stream EOM” using Sybase.AdoNet4.AseClient