Manufacturer part number in email

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 лет назад
This might be a stupid question (I'm a network guy, not a programmer!), but what do you mean by an instance of the database?  The only database I have at the moment is the sample products.  Is that what you meant, or did I just give you a good laugh?

;)
14 лет назад
That's correct.  The problem you may encounter is that GoDaddy won't allow you too much flexibility in terms of what you can change with their hosted version of nopCommerce.  What you really need is your own hosted web space that supports SQL Server.  You can then change and build the nopCommerce code and then upload to your web space.
14 лет назад
@ wmlockhart

hi - can you elaborate on what you mean about godaddy not being too flexible with nopcommerce - i'm considering giving them a go with my much altered cart
14 лет назад
Hi Haydie,

in the conversation with almeras we are talking about GoDaddy's hosted version of nopCommerce, see here:

http://hostingconnection.godaddy.com/AllApplications.aspx?prog_id=GoDaddy

Hosting companies tend to run the compiled version of applications (and rightly so, it improves performance) which means that almeras doesn't have access to the application's source code, which means he can't make the changes to the application that he would like to make.  This is what I meant by GoDaddy not being too flexible in terms of what almeras was tring to achieve (i.e., modifying the source code of a hosted application).

My experience of GoDaddy and other shared hosting organisations is that they typically don't provide you with full Administrator rights on the shared server that you host your application.  Again, the hosting organisation does this for very good reasons.  Security being one.  However, that may not be an issue with nopCommerce.  You may be able to do all that you need to do without full Administrator rights.  You will only find out once you try it.

Search Google with the following words 'nopcommerce godaddy' and you will get some idea of other peoples experience with hosting nopcommerce on GoDaddy.

Let me know how it goes.

Kind Regards

Walter
13 лет назад
Getting back to this original posting...   I can't make this work.   productVariant is not a property of order.  Did anyone make this work?

-------------------------------------------------------------------

you will find the code file MessageManager.cs at the following folder location:

nopCommerce_1_20\Libraries\Nop.Common\Messages\MessageManager.cs

Inside MessageManager.cs there is a function called 'ReplaceMessageTemplateTokens':

        public static string ReplaceMessageTemplateTokens(Order order, string Template, int LanguageID)

Inside this function you will see the 'Tokens' NameValueCollection being initialised with the Token Name and Value pairs.  For example:

        tokens.Add("Order.BillingFirstName", HttpUtility.HtmlEncode(order.BillingFirstName));

adds the value of 'order.BillingFirstName' to the Token name 'Order.BillingFirstName'.

You will need to add a line in this function which takes the value of the 'Manufacturer Part Number' and associates it with a Token name -- for example: "Order.ManufacturerPartNumber".

Then use this Token name "Order.ManufacturerPartNumber" in your templates.

Regards
13 лет назад
In NopCommerce v1.60 the ManufacturerPartNumber apears in the table Nop_ProductVariant.  The Product Variant is related to the Nop_Order via the Nop_OrderProductVariant table.  Each row in the Nop_Order table is effectively the Order Header, and each row in the Nop_OrderProductVariant table is effectively the Order Detail or Line Item.  Many Nop_ProductVariant rows can be related to a Nop_Order via the Nop_OrderProductVariant table.  In fact this is a many-to-many relationship where many Product Variants can be related to many Orders.

So basically, what you've got to do is to get the ManufacturerPartNumber value for each Product Variant associated with the Order and replace the Token in the message with the value.

Take a look through my previous post and follow the steps.  It's all there in the NopCommerce code.  Set a breakpoint in Visual Studio and step through:  public static string ReplaceMessageTemplateTokens(Order order, string Template, int LanguageID)  for instance.  It's a great way to learn.  I've learnt so much from this well-written application.

Kind Regards

Walter
13 лет назад
Hi Walter,
I appreciate the response.  Forgive my inability to see this.  This is not valid:


tokens.Add("Order.ManufacturerPartNumber", HttpUtility.HtmlEncode(order.OrderProductVariants.ManufacturerPartNumber));


order.OrderProductVariants is a collection.  I could do something like a order.OrderProductVariants.find(whatever)

I guess I don't see how to do it without the exposed property called "ManufacturerPartNumber"

Thank you,
Matt
13 лет назад
Hi Matt,

No problem.

Here is what I think you need to do.

I'm using the current release of NopCommerce v1.6

Go to line 1541 in MessageManager.cs:

tokens.Add("Order.Product(s)", ProductListToHtmlTable(order, languageId));

You need to retrieve the ManufacturerPartNumber for each Product (Product Variant) associated with the Order.

To do this, step into: ProductListToHtmlTable (it's in MessageManager.cs).

Go to line 252:

sb.AppendLine("<td style=\"padding: 0.6em 0.4em;text-align: left;\">" + HttpUtility.HtmlEncode(productVariant.FullProductName));

and change it to:

sb.AppendLine("<td style=\"padding: 0.6em 0.4em;text-align: left;\">" + HttpUtility.HtmlEncode(productVariant.ManufacturerPartNumber));

I suggest you do this only for experimental purposes.  This will display the Manufacturer Part Number for each Product associated with Order and not the Full Product Name.

Once you have seen that this works then change the code back to display Full Product Name.

To make this a more permanent change to the application, I suggest you insert the following line after Line 236 (or wherever you want it positioned within the grid / table):

sb.AppendLine(string.Format("<th>{0}</th>", LocalizationManager.GetLocaleResourceString("Order.ProductsGrid.ManufacturerPartNumber", languageId)));

You will then need to insert a row in the table Nop_LocaleStringResource for each of the active Languages in your system - with a ResourceValue of say 'Mfr Part No.' or whatever you choose for the English language.

Then insert the line:

sb.AppendLine("<td style=\"padding: 0.6em 0.4em;text-align: left;\">" + HttpUtility.HtmlEncode(productVariant.ManufacturerPartNumber));

after the current Line 252 so that you have something like:

sb.AppendLine("<td style=\"padding: 0.6em 0.4em;text-align: left;\">" + HttpUtility.HtmlEncode(productVariant.FullProductName));
sb.AppendLine("<td style=\"padding: 0.6em 0.4em;text-align: left;\">" + HttpUtility.HtmlEncode(productVariant.ManufacturerPartNumber));

This should work.  Give it a go.

Let me know the outcome - either way.

Kind Regards

Walter
13 лет назад
Walter - This was incredibly helpful.  Thanks for your help.

Based upon your instructions, I got this to work.

Thanks again,
Matt
13 лет назад
Matt. Excellent. Walter.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.