Cart+Checkout Plugin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
I need to add a field to the products model, and route products into the cart to be displayed and paid in a specific way if this field is enabled.

Simple enough. I understand extending the model by adding the field value, but I need to understand a few things about properly routing and getting into the right controller and view.

If I extend the model with a new field where should I put the code for the editor of this model? If I create a new view do I need to reimplement the whole Catalog view in my plugin or just the page where the editor appears in the admin? If so how do I get the route to correctly render this view?

If this new field determines what version of information is displayed in the cart do I just need to extend the carts view or completely reimplement the cart and route into it?

I think this has to easier than I'm making it out to be I just don't understand how to route to my specialized components without completely copying everything into my plugin?

So In short I need a Boolean field on the product, I need to add an editor for this field to the default product editor!

Thanks

Update

Here are some notes on parts that need to be implemented (I'm hoping to get some suggestions on how to do this)

Web.Admin views need to be extended to include a 'checkbox' for this field on Create/Update of Product (if it applies to one product, it will apply to all attributes, so I don't need to do it by attribute)

Nop.Admin\Models\Catalog\ProductModel.cs
        //SC
        // TODO: needs to be extended to include install for fieldname
        [NopResourceDisplayName("Special Checkout Product")]
        public bool isSpecialCheckoutProduct { get; set; }
        // End SC


Nop.Admin\Views\Product\_CreateOrUpdate.cshtml

        <!-- SC -->
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.isSpecialCheckout):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.isSpecialCheckout
                @Html.ValidationMessageFor(model => model.isSpecialCheckout)
            </td>
        </tr>
        <!-- /SC -->


Additionally, the 'model' returned from the form is 'mapped' to a product entity:

product = model.ToEntity(product);


My new field is not being mapped correctly the product entity before it is updated int he database? Ok, I was able to add the following:

Nop.Core/Domain/Catalog/Product.cs
        public virtual string isSpecialCheckoutProduct { get; set; }


Now I'm correctly mapping the field - which triggers CF to kick in..but still not sure how to regenerate my database: DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.!

Not sure how to route these specific attributes into the page without reimplementing the entire controller in my plugin - and even than - not sure how to over-ride the 'Admin' routes to make sure I go to my custom views/models/controllers etc., after the plugin is installed.

I think I'm having to rebuild my SQL CE Database each time to sweep in the new code-first property - but I would prefer to go on working, but I need to install SQL CE 4 to edit my .sdf file and add the field correct!?
12 years ago
This is sort of a bump - SO can anyone give me advice about successfully routing into my own version of the 'cart' page when the product's model is extended to include my extra field->


if(product.isSpecialCheckout){
      //route to 'special checkout'
}
else{
     //standard checkout
}


How will the 'view' know which button to display? Can I trick the view into over-riding the default somehow from within my plugin?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.