Custom Plugin Help

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
12 years ago
I created my own custom shipping plugin to allow us to charge a flat amount PER ITEM.  The tutorial was great and my plugin is working as expected.  I wanted to submit it in case anyone else ever wanted to use it, but I noticed in my plugin directory I have a TON of extra files that the other plugins don't have. I have all of the language directories it looks like plus all of the reference files like Nop.Core.dll and a bunch others. I know I used these as reference files, but how do I get it not to actually put all of these files in the plugin directory and just use the files that already exist in my nopCommerce installation? All of the other plugins only have their associated DLL file and the Description.txt file.

Thanks all!
12 years ago
Remove the assemblies from the plugin's output path and ensure that the "Copy Local" property is set to False for the referenced assemblies in your plugin project. You can then "Build" your plugin project to have only the project assembly and Description.txt copied to the output path.

See "Tip 4" on the Developer Documentation / How to write a nopCommerce plugin page.

.
12 years ago
clucernoni wrote:
I created my own custom shipping plugin to allow us to charge a flat amount PER ITEM.  


Curious to see it, though I think you can get the same affect by using  "Additional shipping charge" on each product variant:

Setting up a Shipping Method called "Flat Rate", use plugin Shipping.FixedRate - Configure Fixed Rate Shipping setting $0 for "Flat Rate" and then use "Additional shipping charge" on each product variant.
12 years ago
Thank you very much for the help.

I guess I probably could have gotten the same effect by setting it per product variant, but this was seems easier and more straightforward. Especially if you have a lot of products and your shipping rate will always be the same per product, like our situation.

Thanks all again for the help!
12 years ago
If "shipping rate will always be the same per product"  then why not just use Fixed Rate plugin?
12 years ago
New York wrote:
If "shipping rate will always be the same per product"  then why not just use Fixed Rate plugin?

The fixed rate plugin does not take into account the number of products. So if you set the fixed rate to $10, it's going to be $10 for an order with 1 item or 100 items.
12 years ago
Yes, I see what you're trying to do - basically a "Shipping By Unit" rate calc.
(Although as a customer, I suppose I might be put off by not getting a better shipping rate if I ordered many products.)

I suppose another "workaround" would be to use the ShippingByWeight plugin - if you didn't need actual product weights for anything else, you could set them all to "1".  Then you could configure the rates so that,, for example, 1-3 lbs was $x per lb, and 4-6 lbs was $y per lb, etc.

(Or of course, shameless plug - you can create more complex rate calculations using Shipping.Director plugin  [url]www.nopTools.com[/url]  :)
12 years ago
Hi all,

I am trying to write a custom payment method similar to redirect, but based on post. The payment gateway requires a form submit that has some encrypted data which includes order ID among other fields. I cannot submit this form from the web server because user must be sent to gateway page where payment would take place. Gateway then would redirect user to a specified url.

What I would like to do is use PaymentInfo() method of controller to prepare a form that would contain all necessary information as hidden variables for user to submit to the gateway. My problem is that order is not yet saved at that point. I know this idea goes against the design, but I don't see another option at the first glance.

I unerstand PostProcessPayment is designed to help with redirect, but is there a way I can make it work with post having the requirements above?

My guess is I can create an intermediate page, redirect to it from PostProcessPayment, then construct html with required form, show it to user and allow user submit the form to the gateway, but that would require an extra step (and more coding).

I would appreciate your advice and/or a pointer to similar payment method example.

-dmitriy
12 years ago
@dmitriy_burdan
You may want to start a new post to get better response.  This one started as the Local Copy problem, and then digressed to shipping, but not payment methods.


@clucernoni

Although I've not installed your plugin, I looked at the code.  I think you have a bug.  It's probably not likely that your plugin would be used with multiple methods set up (e.g. in store pickup, ground, air), but if it ever was (e.g. pickup at store A, pickup at store B) only the first method would have accurate rate, since int totalItemCount = 0; is before the outer loop.

            var shippingMethods = this._shippingService.GetAllShippingMethods(restrictByCountryId);
            int totalItemCount = 0;
            foreach (var shippingMethod in shippingMethods)
            {
                var shippingOption = new ShippingOption();
                shippingOption.Name = shippingMethod.GetLocalized(x => x.Name);
                shippingOption.Description = shippingMethod.GetLocalized(x => x.Description);
                //this is a fixed rate shipping per item method. Multiply the fixed rate by the number of items.
                //find out how many items are in the cart
                foreach(ShoppingCartItem item in getShippingOptionRequest.Items){
                    totalItemCount += item.Quantity;
                }
                shippingOption.Rate = totalItemCount * GetRate(shippingMethod.Id);
                response.ShippingOptions.Add(shippingOption);
            }
12 years ago
New York wrote:
@dmitriy_burdan
You may want to start a new post to get better response.  This one started as the Local Copy problem, and then digressed to shipping, but not payment methods.


@clucernoni

Although I've not installed your plugin, I looked at the code.  I think you have a bug.  It's probably not likely that your plugin would be used with multiple methods set up (e.g. in store pickup, ground, air), but if it ever was (e.g. pickup at store A, pickup at store B) only the first method would have accurate rate, since int totalItemCount = 0; is before the outer loop.

            var shippingMethods = this._shippingService.GetAllShippingMethods(restrictByCountryId);
            int totalItemCount = 0;
            foreach (var shippingMethod in shippingMethods)
            {
                var shippingOption = new ShippingOption();
                shippingOption.Name = shippingMethod.GetLocalized(x => x.Name);
                shippingOption.Description = shippingMethod.GetLocalized(x => x.Description);
                //this is a fixed rate shipping per item method. Multiply the fixed rate by the number of items.
                //find out how many items are in the cart
                foreach(ShoppingCartItem item in getShippingOptionRequest.Items){
                    totalItemCount += item.Quantity;
                }
                shippingOption.Rate = totalItemCount * GetRate(shippingMethod.Id);
                response.ShippingOptions.Add(shippingOption);
            }

You are quite right. I will update it and move it inside the loop. I only will ever use it with one method.

Thanks!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.