1 line changes to nop with significant impact

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 年 前
1) Product.aspx.cs line 72+ add in:

if (product.MetaDescription == "")
                product.MetaDescription = product.ShortDescription;

I.E if product SEO is blank use description

2) /Templates/Products/* - Change product title to <h1>

3) CheckoutPaymentMethod.ascx.cs

If there is only 1 checkout method, automatically select it:

Line 208:


else if (boundPaymentMethods.Count == 1)
            {
                phSelectPaymentMethod.Visible = true;
                pnlPaymentMethodsError.Visible = false;
                dlPaymentMethod.DataSource = boundPaymentMethods;
                dlPaymentMethod.DataBind();

                // Theres only one paymeny method, so no point in asking the user to select it

                int paymentMethodId = boundPaymentMethods[0].PaymentMethodId;
                var paymentMethod = PaymentMethodManager.GetPaymentMethodById(paymentMethodId);
                if (paymentMethod != null && paymentMethod.IsActive)
                {
                    NopContext.Current.User = CustomerManager.SetLastPaymentMethodId(
                        NopContext.Current.User.CustomerId, paymentMethodId);
                    var args1 = new CheckoutStepEventArgs() {PaymentMethodSelected = true};
                    OnCheckoutStepChanged(args1);
                    if (!this.OnePageCheckout)
                        Response.Redirect("~/checkoutpaymentinfo.aspx");
                }
            }


4) CheckoutBillintAddress.ascx.cs

When clicking Use Same as Shipping address button use this:

SelectAddress(billingAddress);

This will automatically select the address for the user and move to next step. Rather than copying values then having to click next.
13 年 前
Thanks
13 年 前
Add search by key or value to localization:

File: NopCommerceStore\Administration\Modules\LocaleStringResources.ascx
Line: add at 23

    <td class="adminTitle" style="padding-left:25px; white-space:nowrap" runat="server" id="tdSearch">
      <%=GetLocaleResourceString("Admin.LocaleStringResources.PageSize")%>: <asp:DropDownList runat="server" ID="ddlPageSize" AutoPostBack="true" Style="margin-right:20px;" OnSelectedIndexChanged="ddlPageSize_SelectedIndexChanged" />

      <%=GetLocaleResourceString("Admin.LocaleStringResources.SearchByKey")%>
      <asp:TextBox ID="txtSearchByKey" runat="server" />
      <asp:Button runat="server" ID="btnSearchByKey" CssClass="adminButtonBlue" Text="<% $NopResources:Admin.LocaleStringResources.SearchButton.Text %>"
        OnClick="btnSearchByKey_Click" ToolTip="<% $NopResources:Admin.LocaleStringResources.SearchButton.Tooltip %>" Style="margin-right:20px;" />
      
      <%=GetLocaleResourceString("Admin.LocaleStringResources.SearchByValue")%>
      <asp:TextBox ID="txtSearchByValue" runat="server" />
      <asp:Button runat="server" ID="btnSearchByValue" CssClass="adminButtonBlue" Text="<% $NopResources:Admin.LocaleStringResources.SearchButton.Text %>"
        OnClick="btnSearchByValue_Click" ToolTip="<% $NopResources:Admin.LocaleStringResources.SearchButton.Tooltip %>" />
    </td>



File: NopCommerceStore\Administration\Modules\

at the end of "FillDropDowns()":

      this.ddlPageSize.Items.Clear();
      Enumerable.Range(1, 20).ToList().ForEach(x => ddlPageSize.Items.Add((x * 100).ToString()));


in "BindGrid()" after "var resourceDictionary = language.LocaleStringResources;"

        gvLocaleStringResources.PageSize = int.Parse(ddlPageSize.SelectedValue);
        
        if ( !String.IsNullOrWhiteSpace(txtSearchByKey.Text) ) {
          txtSearchByKey.Text = txtSearchByKey.Text.ToLower();
          resourceDictionary = resourceDictionary
            .Where(x => !String.IsNullOrEmpty(x.Value.ResourceName) && x.Value.ResourceName.ToLower().Contains(txtSearchByKey.Text))
            .ToDictionary(x => x.Key, x => x.Value);
        }
        if ( !String.IsNullOrWhiteSpace(txtSearchByValue.Text) ) {
          txtSearchByValue.Text = txtSearchByValue.Text.ToLower();
          resourceDictionary = resourceDictionary
            .Where(x => !String.IsNullOrEmpty(x.Value.ResourceValue) && x.Value.ResourceValue.ToLower().Contains(txtSearchByValue.Text))
            .ToDictionary(x => x.Key, x => x.Value);
        }
        tdSearch.Visible = ddlLanguage.SelectedIndex > 0;


at the end of "BindGrid()":

ddlPageSize.Visible = tdSearch.Visible = btnAddNew.Visible;


at the end of file:

    protected void btnSearchByKey_Click(object sender, EventArgs e)
    {
      txtSearchByValue.Text = null;
      BindGrid();
    }
    protected void btnSearchByValue_Click(object sender, EventArgs e)
    {
      txtSearchByKey.Text = null;
      BindGrid();
    }
    protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
    {
      BindGrid();
    }
13 年 前
Could you explain how to skip the payment method for version 1.9?

There is no more PaymentMethodManager.

The code has a comment:
//or you can select it and go to the next step of checkout

but I don't know how to actually select the only available payment method.

Your help is much appreciated.
13 年 前
in v1.9  the payment method is automatically skipped if the order total is 0.00
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.