Adding SKU to the invoice .pdf

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
In this step I will reference the data Lane, Bay, and Stock code that you have added to nopcommerce as:

XXXXX.XXX. ProductCCCLane
XXXXX.XXX. ProductCCCBay
and
XXXXX.XXX. ProductCCCStockCode

//Lane
cell = new PdfPCell(new Phrase(XXXXX.XXX.ProductCCCLane , font));
cell.HorizontalAlignment = Element.ALIGN_LEFT;
productsTable.AddCell(cell);

//Bay
cell = new PdfPCell(new Phrase(XXXXX.XXX.ProductCCCBay, font));
cell.HorizontalAlignment = Element.ALIGN_LEFT;
productsTable.AddCell(cell);

//Stock code
cell = new PdfPCell(new Phrase(XXXXX.XXX.ProductCCCStockCode, font));
cell.HorizontalAlignment = Element.ALIGN_LEFT;
productsTable.AddCell(cell);

Hi thank you where would I find out the reference to data in the code, in the ProductMap.cs file I have referenced these feilds as follows? Is it there. As mentioned I am a novice........ Thank you.


this.Property(p => p.CCCBay).HasMaxLength(2);
this.Property(p => p.CCCLane).HasMaxLength(2);
this.Property(p => p.CCCStockCode).HasMaxLength(9);


PS.

We are a small wholesale and retail company. Our website is still under construction due to a change over in our existing system when it is up and fully running I will post the link...
11 years ago
//Lane
                    cell = new PdfPCell(new Phrase(pv.Product.CCCLane, font));
                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                    productsTable.AddCell(cell);

                    //Bay
                    cell = new PdfPCell(new Phrase(pv.Product.CCCBay, font));
                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                    productsTable.AddCell(cell);

                    //Stock code
                    cell = new PdfPCell(new Phrase(pv.Product.CCCStockCode, font));
                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                    productsTable.AddCell(cell);


Here is the code I used and it worked fine..

I have one more question is it possible to generate two PDF's I spoke to the Managing director and we are wondering instead of using the stickers we could use it as a picking list so we have an order invoice and a picking list?

Richard
11 years ago
Sorry it took me so long to get back to you.  So what you are wanting is another PDF invoice accessible from the admin?  For instance a “Picking List (PDF)” next to the “Invoice (PDF)”?  I needed the same type of thing for my business. Here is the changes that I made.

Steps to adding a new PDF Invoice

To add a whole new PDF invoice requires many steps.   I have written out the steps for you below.
I am not an expert, so some of these steps may not be necessary however you might want to do them all to make sure it works.

Step #1

You will have to edit PdfService.cs

This can be found under

Libraries  - > Nop.Services - > Common - > PdfService.cs

You need to copy the code for the PDF Invoice Starting at

/// <summary>
/// Print an order to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="lang">Language</param>
/// <param name="filePath">File path</param>

....

and ending before:

/// <summary>
/// Print packaging slips to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="filePath">File path</param>

This chunk of code is what generates the PDF.  Past the code that you copied right before the

/// <summary>
/// Print packaging slips to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="filePath">File path</param>

At the beginning of the code that you just copied you should see:

/// <summary>
/// Print an order to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="lang">Language</param>
/// <param name="filePath">File path</param>
public virtual void PrintOrdersToPdf(IList<Order> orders, Language lang, string filePath)
        {
            if (orders == null)
....

You will need to make the following changes:

/// <summary>
/// Picking List to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="lang">Language</param>
/// <param name="filePath">File path</param>
public virtual void PickingListToPdf(IList<Order> orders, Language lang, string filePath)
        {
            if (orders == null)
...

Step #2

You will have to edit IPdfService.cs

This can be found under

Libraries  - > Nop.Services - > Common - > IPdfService.cs

Near the top of this file you will see the following code:

/// <summary>
/// Print an order to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="lang">Language</param>
/// <param name="filePath">File path</param>
void PrintOrdersToPdf(IList<Order> orders, Language lang, string filePath);

Add this code right below the code that I have shown above:

/// <summary>
/// Picking List to PDF
/// </summary>
/// <param name="orders">Orders</param>
/// <param name="lang">Language</param>
/// <param name="filePath">File path</param>
void PickingListToPdf(IList<Order> orders, Language lang, string filePath);

Step #3

You will have to edit OrderController.cs

This can be found under

Presentation - > Nop.Web- > Controllers - >  OrderController.cs

Under the #region Utilities details scroll down till you find the following code:

model.DisplayPdfInvoice = _pdfSettings.Enabled;

Right below this code add the following code:

model.DisplayPickingListInvoice = _pdfSettings.Enabled;

Also, under the #region Order details scroll down till you find the following code:

public ActionResult GetPdfInvoice(int orderId)
{
var order = _orderService.GetOrderById(orderId);
if (order == null || order.Deleted || _workContext.CurrentCustomer.Id !=     order.CustomerId)
return new HttpUnauthorizedResult();

var orders = new List<Order>();
orders.Add(order);
string fileName = string.Format("order_{0}_{1}.pdf", order.OrderGuid, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss")); string filePath = string.Format("{0}content\\files\\ExportImport\\{1}",this.Request.PhysicalApplicationPath, fileName);
_pdfService.PrintOrdersToPdf(orders, _workContext.WorkingLanguage, filePath);
var pdfBytes = System.IO.File.ReadAllBytes(filePath);
return File(pdfBytes, "application/pdf", fileName);
}


Right below this code add the following code:


public ActionResult GetPickingListInvoice(int orderId)
{
var order = _orderService.GetOrderById(orderId);
if (order == null || order.Deleted || _workContext.CurrentCustomer.Id != order.CustomerId)
   return new HttpUnauthorizedResult();

var orders = new List<Order>();
orders.Add(order);
string fileName = string.Format("order_{0}_{1}.pdf", order.OrderGuid, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
string filePath = string.Format("{0}content\\files\\ExportImport\\{1}", this.Request.PhysicalApplicationPath, fileName);
_pdfService.PickingListToPdf(orders, _workContext.WorkingLanguage, filePath);
var pdfBytes = System.IO.File.ReadAllBytes(filePath);
return File(pdfBytes, "application/pdf", fileName);
}


Note:  The code that I have copied into the forum will need to look a little different in Visual Studio because the copied code does not have the right page breaks.  Throughout these steps look at the code for the “Invoice (PDF)” and make sure the code that you put below it is formatted the same way.

Step #4

You will have to edit OrderController.cs

This can be found under

Presentation - > Nop.Web- > Administration - > Controllers  - >  OrderController.cs

Note: This looks like the same file as in step #3 but it is in a different place so make sure you edit this file as well.
Under #region Utilities scroll down till you find the following code:

model.DisplayPdfInvoice = _pdfSettings.Enabled;

Right below this code add the following code:

model.DisplayPickingListInvoice = _pdfSettings.Enabled;

Also, under the #region Order details scroll down till you find the following code:

public ActionResult PdfInvoice(int orderId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();

var order = _orderService.GetOrderById(orderId);
var orders = new List<Order>();
orders.Add(order);
string fileName = string.Format("order_{0}_{1}.pdf", order.OrderGuid, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
string filePath = string.Format("{0}content\\files\\ExportImport\\{1}", this.Request.PhysicalApplicationPath, fileName);
_pdfService.PrintOrdersToPdf(orders, _workContext.WorkingLanguage, filePath);
var bytes = System.IO.File.ReadAllBytes(filePath);
return File(bytes, "application/pdf", fileName);
}

Right below this code add the following code:

public ActionResult PickingListInvoice(int orderId)
{
if (!_permissionService.Authorize(StandardPermissionProvider.ManageOrders))
return AccessDeniedView();

var order = _orderService.GetOrderById(orderId);
var orders = new List<Order>();
orders.Add(order);
string fileName = string.Format("order_{0}_{1}.pdf", order.OrderGuid, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
string filePath = string.Format("{0}content\\files\\ExportImport\\{1}", this.Request.PhysicalApplicationPath, fileName);
_pdfService.PickingListToPdf(orders, _workContext.WorkingLanguage, filePath);
var bytes = System.IO.File.ReadAllBytes(filePath);
return File(bytes, "application/pdf", fileName);
}

Step #5

You will have to edit defaultResources.public.nopres.xml

This can be found under

Presentation - > Nop.Web- > Administration - > App_Data  - >  defaultResources.public.nopres.xml

Scroll down till you find the following code:

<LocaleResource Name="GetPDFInvoice">
<Value>PDF Invoice</Value>
</LocaleResource>

Right below this add the following code:

<LocaleResource Name="GetPickingListInvoice">
<Value>Picking List Invoice</Value>
</LocaleResource>

Step #6

You will have to edit RouteProvider.cs

This can be found under

Presentation - > Nop.Web- > Infrastructure -> RouteProvider.cs

Scroll down till you find the following code:

routes.MapLocalizedRoute("GetOrderPdfInvoice",
"orderdetails/pdf/{orderId}",
new { controller = "Order", action = "GetPdfInvoice" },
new[] { "Nop.Web.Controllers" });

Right below this code add the following code:

routes.MapLocalizedRoute("GetOrderPickingListInvoice",
"orderdetails/pdf/{orderId}",
new { controller = "Order", action = "GetPickingListInvoice" },
new[] { "Nop.Web.Controllers" });

Step #7

You will have to edit OrderDetailsModel.cs

This can be found under

Presentation - > Nop.Web- > Models -> Order -> OrderDetailsModel.cs

Scroll down till you find the following code:

public bool DisplayPdfInvoice { get; set; }

Right below this code add the following code

public bool DisplayPickingListInvoice { get; set; }


Step #8

You will have to edit OrderModel.cs

This can be found under

Presentation - > Nop.Web- > Administration - > Models -> Order -> OrderModel.cs

Scroll down till you find the following code:

public bool DisplayPdfInvoice { get; set; }

Right below this code add the following code:

public bool DisplayPickingListInvoice { get; set; }

Step #9

You will have to edit Edit.cshtml

This can be found under

Presentation - > Nop.Web- > Administration - > Views -> Order -> Edit.cshtml

Near the top you should find the following code:

@if (Model.DisplayPdfInvoice)
{
<a href="@Url.Action("PdfInvoice", new { orderId = Model.Id })" class="t-button">@T("Admin.Orders.PdfInvoice")</a>
}

Right below this code add the following code:

@if (Model.DisplayPickingListInvoice)
{
<a href="@Url.Action("PickingListInvoice", new { orderId = Model.Id })" class="t-button">@T("Picking List (PDF)")</a>
}

Step #10

Run Nopcommerce go to

Sales - > Orders

View an order and see if there is a “Picking List (PDF)” next to “Invoice (PDF)”
If it works, all you have left to do is go back to PdfService.cs in Step #1 and edit the code that you copied in to make the “Picking List (PDF)” show what you want it to.

I hope that I have not made an error when typing this up.  Let me know if you get it to work!
11 years ago
YESS perfect works a charm!!!

Thank you...

I have a couple of question if you have the time though!!

There is one more cell we need to add CCCPack I followed the structure you laid out but this cell doesn't work and the error is as follow's -
Error  2  Argument 1: cannot convert from 'int?' to 'float'  
Error  3  Argument 2: cannot convert from 'iTextSharp.text.Font' to 'string'  

//CCC Pack
                    cell = new PdfPCell(new Phrase(pv.Product.CCCPack, font));
                    cell.HorizontalAlignment = Element.ALIGN_LEFT;
                    productsTable.AddCell(cell);


In Nop.Domain - Catalog - Product.cs Due to some feilds being Null I was advised to create a virtual int?

/// <summary>
        /// Gets or sets CCCPack
        /// </summary>
        public virtual int? CCCPack { get; set; }


In Nop.Data - Catalog - ProductMap.cs I have generated this code.

this.Property(p => p.CCCPack);


This feild for us is nessercary on both PDF files if you could help I would be very humble.

Kind regards

Richard

PS. I am also running into another problem that I was wondering you could help me with If can.

PS 2. Who do you work for and also I noticed you are in the States which part :D

THANK YOU.........
11 years ago
wertyuio1 wrote:

YESS perfect works a charm!!!

Thank you...


I am glad you got it to work!  There were so many things to change I was afraid I might have left one out...

wertyuio1 wrote:


//CCC Pack
cell = new PdfPCell(new Phrase(pv.Product.CCCPack, font));
cell.HorizontalAlignment = Element.ALIGN_LEFT;
productsTable.AddCell(cell);



Try changing the code that you wrote above as follows:


    //CCC Pack
    cell = new PdfPCell(new Phrase(pv.Product.CCCPack.ToString(), font));
    cell.HorizontalAlignment = Element.ALIGN_LEFT;
    productsTable.AddCell(cell);

Just to test it, I created a new column as CCC Pack, and since I didn't have your code I decided to populate the column I made with the NotApprovedRatingSum of the products.  The NotApprovedRatingSum is also "public virtual int" in Nop.Domain - Catalog - Product.cs like the CCC Pack that you have written.  I found that to get it to work you needed the ".ToString()" part.  Without the ".ToString()" you get:

Error:
The best overloaded method match for 'iTextSharp.text.Phrase(float, string)' has some invalid arguments

I am not sure that this is the same error you are having but I think it is worth a try. :)

If this does not work try changing pv.Product.CCCPack.ToString() to pv.Product.NotApprovedRatingSum.ToString().  If it works for the NotApprovedRatingSum then the problem is most likely something you did with the CCC Pack code.

wertyuio1 wrote:

PS. I am also running into another problem that I was wondering you could help me with If can.


I would love to help, but I am not really a developer so I might not know the answer. :)  It turns out that the two things that you asked: creating more columns on the PDF invoice and Creating another PDF invoice were both things that I had to figure out for the business that I started so I already had something to go on.  

However, if I don't know the answer, I am sure there is someone who does.  This forum is a great place to get help.

wertyuio1 wrote:

PS 2. Who do you work for and also I noticed you are in the States which part :D


I work for myself in the business that I started, however for the main part I am a student.  I live in Virginia.
  

I hope this fixes the problem you had.

Let me know if it works!
11 years ago
Yes It did work again fantastic. !!!

Sorry for my delay time zones I'm over the pond in Great Britain currently and we actually have sun!!.

I'm an apprentice programme developer I have only been working this area for 7 months steep but fantastic learning curve.

I have to more question's concerning the Pdf's if okay.

Then my other question If you are able to help with concerns a partial view for product display.

But If we can try and get the PDF'S ticked of the list then I can move on to the next.. :D

With The PDF in the picking form the Total column is it product total or overall price total, My thoughts on this are I have notice that the following feilds

Sub-total: $0.00
Shipping: $0.00
Tax: $0.00
Order total: $0.00

Is there a way of incorperating the order total into the total column / or is it product total??? If it is a product total can I change it to the overall price total.


So if a customer order Qty is 4 that contain's 6 packs each pack costs £2 so the total sum in the total column will be £48

(I hope my maths is right) I hope you see where I coming from.

Also with the header logo on the picking list created how do I assign the header logo for my company??

Once again thank you

Richard...
11 years ago
wertyuio1 wrote:

Also with the header logo on the picking list created how do I assign the header logo for my company??


To set the Logo for your company go to

Admin -> Configuration -> General And Miscellaneous Settings ->

Then click on the PDF Settings tab.  You can set the logo here.

wertyuio1 wrote:

With The PDF in the picking form the Total column is it product total or overall price total, My thoughts on this are I have notice that the following feilds

Sub-total: $0.00
Shipping: $0.00
Tax: $0.00
Order total: $0.00

Is there a way of incorperating the order total into the total column / or is it product total??? If it is a product total can I change it to the overall price total.


The total column is simply the Qty * (The product price).  
The sub-total is the sum of all the values that you see in the total column.

The problem that you might have changing the total column to display the order total for each of the products instead of the sub-total for each of the products is that I think that the Shipping, tax, and Order total are based of of the Sub-total for the products as a whole not individually.  I am not sure but these values, Shipping, tax, and Order total might be saved in the database base off of the sub-total of all the products.  If this is the case, it will be harder to change.  Maybe someone else might be able to expound on this, I am not sure. :)

wertyuio1 wrote:

So if a customer order Qty is 4 that contain's 6 packs each pack costs £2 so the total sum in the total column will be £48

(I hope my maths is right) I hope you see where I coming from.


I am not sure I understand, but could you have a "6 pack" product variant that was £12.  If someone bought a quantity of 4 of the "6 pack" product variant then the total column would be £48.
11 years ago
Sorry for my late reply - hell of a day been setting up my web server ready to take to the data centre :D

I am not sure I understand, but could you have a "6 pack" product variant that was £12.  If someone bought a quantity of 4 of the "6 pack" product variant then the total column would be £48.

I'm probably confusing the matter - In our db our pack size vary's on size but has a wholesale price that remains the same. If we take the variants out completely. The qty of packs added gives the total sum of the price / sub total!! Ill have to test the procedures with the data.

If you don't mind asking you another question I have asked on the forum, but I having a problem with a view for product display.

I have created a productpop that for the life of me over the last few months I can't get to display... Here is the code I have generated alongside Nop two!

Nop.Web - Controller - Catalog Controller

        
public ActionResult _Productpopup(int productId)
        {
            var product = _productService.GetProductById(productId);

            //prepare the model
            var model = PrepareProductDetailsPageModel(product);

            //CCCStockCode
            model.CCCStockCode = product.CCCStockCode;

            ////CCCPack
            model.CCCPack = product.CCCPack;

            ////CCCLane
            model.CCCLane = product.CCCLane;

            ////CCCRRP
            model.CCCWholesalePrice = product.CCCWholesalePrice;

            ////CCCRetailPrice
            model.CCCRetailPrice = product.CCCRetailPrice;

            ////CCCMRP
            model.CCCMRP = product.CCCMRP;

            ////CCCQTYINSTOCK
            model.CCCQTYINSTOCK = product.CCCQTYINSTOCK;

            ////CCCBay
            model.CCCBay = product.CCCBay;

            ////CCCSourceBarcode
            model.CCCSourceBarcode = product.CCCSourceBarcode;

            ////CCCRetailBarcode
            model.CCCRetailBarcode = product.CCCRetailBarcode;

            ////CCCWeight
            model.CCCWeight = product.CCCWeight;

            ////CCCQTYPacksPerLayer
            model.CCCQTYPacksPerLayer = product.CCCQTYPacksPerLayer;

            ////CCCQTYLayersPerPallet
            model.CCCQTYLayersPerPallet = product.CCCQTYLayersPerPallet;

            //CCCQTYLayersPerPallet
            model.CCCQTYTotalPerPallet = product.CCCQTYTotalPerPallet;

            //pictures
            model.DefaultPictureZoomEnabled = _mediaSetting.DefaultPictureZoomEnabled;
            var pictures = _pictureService.GetPicturesByProductId(product.Id);
            if (pictures.Count > 0)
            {
                //default picture
                model.DefaultPictureModel = new PictureModel()
                {
                    ImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault(), _mediaSetting.ProductDetailsPictureSize),
                    FullSizeImageUrl = _pictureService.GetPictureUrl(pictures.FirstOrDefault()),
                    Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                    AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                };
                //all pictures
                foreach (var picture in pictures)
                {
                    model.PictureModels.Add(new PictureModel()
                    {
                        ImageUrl = _pictureService.GetPictureUrl(picture, _mediaSetting.ProductThumbPictureSizeOnProductDetailsPage),
                        FullSizeImageUrl = _pictureService.GetPictureUrl(picture),
                        Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                        AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                    });
                }
            }
            else
            {
                //no images. set the default one
                model.DefaultPictureModel = new PictureModel()
                {
                    ImageUrl = _pictureService.GetDefaultPictureUrl(_mediaSetting.ProductDetailsPictureSize),
                    FullSizeImageUrl = _pictureService.GetDefaultPictureUrl(),
                    Title = string.Format(_localizationService.GetResource("Media.Product.ImageLinkTitleFormat"), model.Name),
                    AlternateText = string.Format(_localizationService.GetResource("Media.Product.ImageAlternateTextFormat"), model.Name),
                };
            }

            //check whether we have at leat one variant
            if (model.ProductVariantModels.Count == 0)
                return RedirectToAction("Index", "Home");

            //save as recently viewed
            _recentlyViewedProductsService.AddProductToRecentlyViewedList(product.Id);

            return PartialView();
        }
        }

Nop Web - Views - Catalog - _ProductPopup

@model Nop.Web.Models.Catalog.ProductModel
@{
    Layout = "~/Views/Shared/_RootPopup.cshtml"; ;      
}

      <div class="product-popup">
            <div class="product-details-infopopup">
                <!--product pictures-->
                   <div class="popup-picture">
                     @Html.Partial("_ProductDetailsPictures", Model)
                   </div>
                <div class="overview">
                    <div class="productname">
                     @Model.Name
                    <div class="shortdescription">
                     @Html.Raw(Model.ShortDescription)
                    </div>
                    
                    <div class="stockcode">
                     @Model.CCCStockCode
                    </div>
                    
                    <div class="wholesaleprice">
                    @Model.CCCWholesalePrice
                    </div>

                    <div class="pack">
                    @Model.CCCPack
                    </div>

                    <div class="weight">
                    @Model.CCCWeight
                    </div>

                    <div class="retailprice">
                    @Model.CCCRetailPrice
                    </div>

                    <div class="retailbarcode">
                    @Model.CCCRetailBarcode
                    </div>

                    <div class="sourcebarcode">
                    @Model.CCCSourceBarcode
                    </div>

                    <div class="packsperlayer">
                    @Model.CCCQTYPacksPerLayer
                    </div>

                    <div class="layersperpallet">
                    @Model.CCCQTYLayersPerPallet
                    </div>

                    <div class="totalperpallet">
                    @Model.CCCQTYTotalPerPallet
                    </div>
                    
                    </div>
                    
                    <div class="product-close-button">
                    <input type="button" value="Close" onclick='close()' />
                    </div>
                    
                  </div>
                
                </div>
            
             </div>


In

Nop Web - Views - Catalog - _ProductBox I have adjusted the following code highlighted, now I had it work but I upgraded Nop and for some reason I can't get it to work...

@model Nop.Web.Models.Catalog.ProductModel
<div class="product-item">
    <h2 class="product-title">
        <a href="@Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName, CCCStockCode = Model.CCCStockCode, CCCWholesalePrice = Model.CCCWholesalePrice, CCCPack = Model.CCCPack, CCCWeight = Model.CCCWeight, CCCRetailPrice = Model.CCCRetailPrice, CCCRetailBarcode = Model.CCCRetailBarcode, CCCSourceBarcode = Model.CCCSourceBarcode, CCCQTYPacksPerLayer = Model.CCCQTYPacksPerLayer, CCCQTYLayersPerPallet = Model.CCCQTYLayersPerPallet, CCCQTYTotalPerPallet = Model.CCCQTYTotalPerPallet})">@Model.Name</a>
    </h2>
    <div class="picture">
       <a href="javascript:window.open(@Html.Action("_Productpopup", new { productId = Model.Id, SeName = Model.SeName, CCCStockCode = Model.CCCStockCode, CCCWholesalePrice = Model.CCCWholesalePrice, CCCPack = Model.CCCPack, CCCWeight = Model.CCCWeight, CCCRetailPrice = Model.CCCRetailPrice, CCCRetailBarcode = Model.CCCRetailBarcode, CCCSourceBarcode = Model.CCCSourceBarcode, CCCQTYPacksPerLayer = Model.CCCQTYPacksPerLayer, CCCQTYLayersPerPallet = Model.CCCQTYLayersPerPallet, CCCQTYTotalPerPallet = Model.CCCQTYTotalPerPallet })"

       title="@Model.DefaultPictureModel.Title"> <img alt="@Model.DefaultPictureModel.AlternateText" src="@Model.DefaultPictureModel.ImageUrl" title="@Model.DefaultPictureModel.Title"class="product-popup" />
        </a>
    </div>
    <div class="description">
        @Html.Raw(Model.ShortDescription)
    </div>


    <div class="add-info">
        <div class="prices">
            @Html.Partial("_ProductPrice", Model.ProductPrice)
        </div>
        <div class="buttons">
            <input type="button" value="@T("Products.Details")" class="productlistproductdetailbutton" onclick="setLocation('@Url.RouteUrl("Product", new { productId = Model.Id, SeName = Model.SeName })')" />
            @if (!Model.ProductPrice.DisableBuyButton)
            {
                <br />                
                <input type="button" value="@(Model.ProductPrice.AvailableForPreOrder ? T("ShoppingCart.PreOrder") : T("ShoppingCart.AddToCart"))" class="productlistaddtocartbutton" onclick="setLocation('@Url.RouteUrl("AddProductToCart", new { productId = Model.Id })')" />
            }
        </div>
    </div>
</div>


Object reference not set to an instance of an object. Always!!! Any idea's what I am missing

For the life of me I get it to popup thank god I'm bald.. Appreciate all help..

Richard.
11 years ago
Sorry, I am not sure on this one.  I have never done something like this.

You might look at:


In Nop.Web - Controller - Catalog Controller

Scroll down to

       //product details page
        public ActionResult Product(int productId)
        {
            var product = _productService.GetProductById(productId);
            if (product == null || product.Deleted || !product.Published)
                return RedirectToAction("Index", "Home");
       .....

I don't know if this is the case or not but you might see if you can follow the same method that what used to make the product details page.

wertyuio1 wrote:


I have adjusted the following code highlighted, now I had it work but I upgraded Nop and for some reason I can't get it to work...



If this is what is causing the problem do you have a backup of the original code that worked? Also, what version of nopcommerce did it work on and what version did you upgrade to?  There might have been changes to the nopcommerce code that would cause you to have to write your code differently.

If you can't figure it out you might try posting the question under the Development section of this forum and see if one of the nopcommerce developers have the answer.

I am sorry I don't know the answer :(  

If I figure out what you did wrong I will let you know.
11 years ago
Its cool I will post again, I will update you with the Pack Qty Total too when I test..

Thank you again for all the help. :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.