Custom Input Field on Checkout Page in Opencart:3 - opencart

I want to have a Custom Input field under Payment Method, to get GST Tax detail before placing Order. And I am Using Journal 3 Theme. which has a One-Page checkout.
So, i have tried this article:- https://forum.opencart.com/viewtopic.php?t=172521
At catalog/view/theme/journal3/template/journal3/checkout/payment_method.twig ---added this line
<input name="get_gst" type="text" placeholder="{{ custom_gst }}" class="form-control">
At catalog/controller/checkout/payment_method.php
$this->session->data['comment'] = strip_tags($this->request->post['comment']); //Under this line
$this->session->data['your_field'] = strip_tags($this->request->post['get_gst']); //I added this line
At catalog/controller/checkout/confirm.php
$order_data['comment'] = $this->session->data['comment']; //Under this line
$order_data['get_gst'] = $this->session->data['get_gst']; //I added this line
At catalog/model/checkout/order.php
, comment = '" . $this->db->escape($data['comment']) . "' //after this line
, get_gst = '" . $this->db->escape($data['get_gst']) . "' //I added this line
And After All getting this errro...
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
OK
I have noticed a difference that this theme is getting other field data(Like: Comment box) by v-model="order_data.comment" as shown below, rather than name attribute like i used.
<textarea class="form-control" v-model="order_data.comment" placeholder="{{ text_comments }}"></textarea>
So, i also tried this v-model="get_gst" in my input, but then i am getting an empty checkout page.
Anyone know where is Getting ERROR? Thank You in Advance.
Checkout js file

Seems you not properly add to the session your field.
At catalog/controller/checkout/payment_method.php
This line incorrect:
$this->session->data['your_field'] = strip_tags($this->request->post['get_gst']); //I added this line
Should be:
$this->session->data['get_gst'] = strip_tags($this->request->post['get_gst']); //I added this line
Journal 3 them looks great from the first sight... But I do not recommend to use Journal 3 theme. This theme very complicated and ruining OC framework.

The ease solution - you take any field from payment address, which is currently unused (like Address 2), change it's title to "GST Tax detail" in opencart language files catalog/language/en-gb/checkout/checkout.php.
Address list from Account & Address list under billing details of checkout, Both are taking their data from catalog/controller/accout/address.php in protected function getList(). So, we only need to modify checkout/payment_address.tpl file. Just add
<?php echo $address['address_2']; ?>
AFTER
<?php echo $address['address_1']; ?>
We need to add this because OpenCart only show Address 1 field in Payment method & Billing details section on Checkout page. So, by this we can show Address 2 field on it.

Related

Sitecore Web Forms for Marketers, add info to the display-section-legend class

We are on Sitecore 8 using Web Forms for Marketers.
I am trying to identify how to add information to the "display-section-info" class item in a sitecore WFFM form. Looking # The generated code I see an element (display-section-info class) after the Field Legend, and before the starts of our fields. I would like to put some basic information regarding the fields in this element (below has text "THIS IS WHERE I WOULD LIKE TO ADD TEXT").
Here is the source from "View Source" on the browser. Through developer tools I plugged in some info and that is exactly where I want it to go.
<fieldset class="display-section-fieldset">
<legend class="display-section-legend">1. OUTSIDE INTEREST:</legend>
<p class="display-section-info">THIS IS WHERE I WOULD LIKE TO ADD TEXT</p>
<div class="display-section-content">
<div class=" field-border">
<span class=" field-title">
<span class=" field-required">*</span>
In the field below, list exceptions
</span>
Update1:
per Jammycans response I added a few parameters to the section but did not seem to display. items have been published, I also confirmed on the prod DB.
Content Editor
Results:
Thanks in advance
There is no field in the Form Editor to set this information, you can set it directly on the section item itself.
In the Content Editor, expand the form and select the Form Section item. On the section item in the Parameters field set the information field text you need:
<Information>THIS IS WHERE I WOULD LIKE TO ADD TEXT</Information>
You can use the Localized Parameters field if you need to translate the text.
EDIT:
There is a bug in the logic on the default WFFM section view, located in \Views\Form\EditorTemplates\SectionModel.cshtml (for Sitecore 8 update 5 and earlier). On lines 18-21, the code reads:
#if (string.IsNullOrEmpty(Model.Information))
{
<p class="#Model.CssClass display-section-info">#Html.Sitecore().Field("Information", Model.InnerItem)</p>
}
The first line here should read:
#if (!string.IsNullOrEmpty(Model.Information))
Note the "!". That explains why you were seeing the markup previously, even though the parameter was not set. You need to update the code in the view in order to fix it.

Custom fields in confirmation email Opencart 2.0

I have created custom fields for my registration/checkout form with Opencart 2.0. They show up on the admin section under each order, and I have successfully added them to the order_invoice.tpl, but I need to add them to the confirmation email that is sent to the customer. I think I have located the correct controller file: catalog>controller>account>order.tpl But I think the issue is that the code used to print it out in the order_invoice.tpl is referencing a folder or file in the admin side.
This is the code I am trying to execute in catalog>view>theme>yourtheme>template>mail>order.tpl
<?php foreach ($account_custom_fields as $custom_field) { ?>
<strong><?php echo $custom_field['name']; ?></strong>:
<?php echo $custom_field['value']; ?><br />
<?php } ?>
This is the error I get:
Notice: Undefined variable: account_custom_fields in
/home/raphaelseventworks.com/www/ncbaorders/catalog/view/theme/journal2/template/mail/order.tpl
on line 70Warning: Invalid argument supplied for foreach() in
/home/raphaelseventworks.com/www/ncbaorders/catalog/view/theme/journal2/template/mail/order.tpl
on line 70
Does anyone know how print out custom fields in the order confirmation email? Or what code I need to add to catalog>controller>account>order.tpl to make this work?
Thanks!
If i am correct you are trying to send additional values to confirmation email after checkout
you need to work on
catalog/model/checkout/order.php::addOrderHistory()
After order is placed, the order history is changed, here you can load your view file and pass custom values form controller according to your need.
Good Luck

How to write multi line input in Django

I am making a very basic BBS system (like blog) in Django.
I've made a form where user can type in their content which I call 'body' and I declare it as
folowing in the forms.py:
body = forms.CharField(widget= forms.Textarea, label="body",required=True)
and in the models.py,
body = models.TextField()
I somehow can't seem to be able to write multi line texts...
To sum it up,
I can write multiple lines into my form like:
Hello this is test
This is sample test2
333333
But When I submit it,
I only see
Hello this is test This is sample test2 333333
The error happened when display it.
Textarea uses cr\lf to break lines. That is how it would
be saved into db. But html will ignore cr\lf you need to replace cr\lf with <br> or <p>
A template tag linebreaks can help you, when you display it.
{{ value|linebreaks }}

An advanced Find and Replace with RegEx in Sublime Text

I have a directory full of Classic ASP legacy code, and almost all files have something similar to this:
<input type="hidden" name="driverPayment" value="<% =driverPayment %>">
Then later in the code, some JavaScript is running, and doing the following:
var x = document.getElementById('driverPayment')
This works fine in IE, but of course doesn't work anywhere else because there is no ID attribute defined.
The fix is to go through the 1770 files and manually add an ID attribute that matches the name property on the input. So make it like so:
<input type="hidden" name="driverPayment" id="driverPayment" value="<% =driverPayment %>">
Is there a way I can automate this process by using the logic below:
Get input element with a name attribute
If input has id attribute, move to next input
Else add an ID attribute to the input, and give it a name matching the value of the name attribute
I'd like to do this for the 1770 Classic ASP files I have. I am using Sublime Text.
You can use regex to match. My regex isn't great but the following should work. Happy for others to improve on it. I used some regex from this question.
Right Click project folder
Choose "Find in folder" option
Find and replace options appear at bottom of screen. Select the regex option (far left).
Enter
<(?:input)\s+(?=[^>]*\bname\s*=)(?![^>]*\bid\s*=)[^>]*>?(name="driverPayment")
in Find field
Enter
id="driverPayment" name="driverPayment"
in Replace field
Click Replace

adding line breaks and headers in django's admin interface

EDIT: If you are going to give a downvote, at least explain why -.-
Also, read comments if my post is still unclear. I tried to explain it a bit more in the comments but if it is still unclear about what I'm saying, let me know and I will take printscreens and explain using images.
I have created a model like so
class Post(models.Model):
title_of_post = models.CharField(max_length=100)
actual_post = models.TextField()
and I put this model in the admin interface and enabled the admin interface. Now, when I go to 127.0.0.1/admin/ and sign in, I can add this model. The posts created in the Post model can be seen on the homepage (127.0.0.1) so say my "title_of_post" is "title" and my "actual_post" is "the actual post", if I go to 127.0.0.1 I can see both the title and actual post on the homepage. The problem is, when I am in the admin interface and in the actual_post text box / TextField section, suppose I write this.
Something.
else
It would not recognize that I pushed the enter key after the period. I tried
Something. <br>
else
but that also didn't work. It does not go on a new line after the period. Is there any way to go to the next line when inputting information from the text box / TextField in the django admin interface? Is there any way to put headers from the admin interface, not from the template? Essentially, I want to be able to create this html from the admin interface.
<h1>Something.</h1> <br>
else
in order to show html inside a property, you need to place like this in your template:
{{ post.actual_post|safe }}
the safe template filter its good for not escaping html tags inside your template.
And this will print as:
Something
else
intead of:
Something <br /> else