I want to make the items clickable in the transactional mails. I modified the order mail (items/default.phtml) and added the following code:
<?php $_item = $block->getItem() ?>
<?= $block->escapeHtml($_item->getName()) ?>
However when I add the same code to the invoice mail (items/default.phtml) the value of getProductUrl() is empty.
How can I access the product URL in the invoice?
Thanks in advance.
Try this
$product_url= $_item->getOrderItem()->getProduct()->getProductUrl();
<p class="product-name"><?= $block->escapeHtml($_item->getName()) ?></p>
Related
In my laravel 5.7 app I use snowfire/beautymail templates and themsaid/laravel-mail-preview plugin for testing of emails sending at my local laptop.
In content of my email I point to my site with url like
<p class="email_title">
You sent contact us message at {!! $site_name !!} site successfully !
</p>
I made check that these 2 variables are not empty, but checking email at my local disk when
working at my local laptop with laravel-mail-preview enabled and sending emails using configured smtp there are no any link to my site
in content of my email.
I have smtp installed.
In .env of my server app:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_ENCRYPTION=tls
I check recieved emails on yahoo.com, gmail.com accounts.
Why links are not visible ?
Thanks!
Your $site_name is outside the <a></a> tag, so the link will be there but not visible because it has no content.
Change:
<p class="email_title">
You sent contact us message at {!! $site_name !!} site successfully !
</p>
to:
<p class="email_title">
You sent contact us message at {!! $site_name !!} site successfully !
</p>
Is there a way to centralise a typical mailto html string so that the email address can be updated once instead of multiple times across the pages themselves?
Send Mail
Using PHP with $_SESSION you can have a $mail variable set that you spread trough all your webpages.
Example :
index.php
<?php
session_start();
$_SESSION["mail"]=YOUR_MAIL_ADDRESS;
?>
...
Send Mail
PageX.php
<?php
session_start();
<a href="mailto:<?php echo $_SESSION["mail"] ?>?Subject=Hello%20again"
Make just sure that you call this on the top of every pages you want to use this variable.
<?php
session_start();
You can read more here :
http://php.net/manual/fr/reserved.variables.session.php
I have set up a fresh custom template from the scratch for wordpress with only six static pages.
Now, I have two questions/problems:
How do I put up posts (without comments) on one of those pages? The aim is, that five pages are just giving out static content, but only one of those pages should be showing posts like a little diary/blog within an otherwise static website. Right now with the given code (see below) all six pages give out just the static content from "pages" within Wordpress, which is okay, but I just can not figure out, how to put the posts on one single pages of those six.
How can I add a conctact form on one of those static pages? I mean, they are all getting the same input over my index.php or pages.php, but where do I set the PHP code for the contact form and how do I insert it to just one of those pages (for example CONTACT)?
Here is my code up to now:
index.php
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
page.php
<?php get_header(); ?>
<?php if (have_posts()) : while (have_posts()) : the_post();?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php get_footer(); ?>
Thank you in advance.
To clear things up:
Problem 1:
I have a static website in wordpress with six pages (see www.studio-scs.de, if that helps) and those six pages load the content of the pages throughout page.php, of course.
My problem is now, I need ONE of those six pages (for example TERMINE) to show POSTS, while the other six are still showing NO POSTS, but the PAGE content.
But how can I do that, if all links/pages refer to page.php, which has the code to just state PAGE content without POSTS (see above)?
Problem 2:
On one of the other five pages I want to add a contact form, which needs some PHP code in the header, of course.
But how and where do I insert that, if all pages are loaded by page.php with the same code? Do I have to enter that into header.php and just leave it there loaded all the time/pages?
For your First problem create a new Template and put POST function there and add that template in Dashboard-->pages--> right hand side-->Template and choose template from drop down.
e ius
For Problem 2
Add your PHP code to HEADER.php once, that call each time and display only specific page, where it requried.
Excaly i am not getting your point, how ever i think you want to add post and contact form7 on same page.
Then use this code.
<?php /* Template Name:ABC*/ ?>
<?php get_header(); ?>
<?php
global $post;
$args = array( 'numberposts' => LIMIT OF POST, 'category' => CATEGORY ID );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
setup_postdata($post); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php endforeach; ?>
<!--Contact Form Start Here-->
<?php echo do_shortcode('[CONTACT FORM SHOT CODE HERE]'); ?>
<!--Contact Form END Here-->
<?php get_sidebar();
get_footer();
?>
I have a mostly "static" web site with no server-side code and just a little JavaScript. Now I would like to add a contact form. I do not care how I get the contact form data (so just writing this data to a text file in the server will be ok).
What is the simplest solution for this problem? How do people usually handle this?
I believe I can add some server-side code (PHP or something) to handle the form (and write the form data to a file, for instance) but I would prefer a client-side solution.
Use an external tool, they are commonly referred to as "formmailer". You basically submit the form to their server, and they send the form contents via mail to you.
If you don't want that, you have to do something server-sided: Storing data on the server, without having a server side program that accepts the data from the client, is just not possible.
You could install CouchDB and interface that from Javascript :) Everyone could use that then, too :)
The most easy PHP script that stores POST data on your harddisk:
<?php file_put_contents('/path/to/file', serialize($_POST) . "\n", FILE_APPEND); ?>
You can use Google Drive and create form with required fields. and embed code (which will be iframe) in your static web page.
You will be able to get submitted data in spreadsheet.
You can use qontacto . it is a free contact form you can add to any website. it forwards you the messages.
I set up the fwdform service for this exact need.
Just two simple steps to get your form forwarded to your email.
1.Register
Make an HTTP POST request to register your email.
$ curl --data "email=<your_email>" https://fwdform.herokuapp.com/register
Token: 780a8c9b-dc2d-4258-83af-4deefe446dee
2. Set up your form
<form action="https://fwdform.herokuapp.com/user/<token>" method="post">
Email: <input type="text" name="name"><br>
Name: <input type="text" name="email"><br>
Message: <textarea name="message" cols="40" rows="5"></textarea>
<input type="submit" value="Send Message">
</form>
With a couple of extra seconds you can spin up your own instance on Heroku.
I have a form (login form) that appears in all pages (if the user is not logged in).
The form is created from view helper and then directly called in layout.phtml
class Zend_View_Helper_LoginForm extends Zend_View_Helper_Abstract
{
public function loginForm()
{
$login = new Application_Form_Login();
return $login;
}
}
<?php if(!$this->isLoggedIn()): ?>
<div id="login">
New User? Register Here
<?php echo $this->loginForm(); ?>
Forgot Password!
</div>
<?php endif; ?>
Now how to set the action of this form such that i could validate the fields in the same page?
Matthew Weier O'Phinney (the ZF Programmer leader ) has a blogpost about creating your reusable widget exactly like your needs
you should try it ,
http://weierophinney.net/matthew/archives/246-Using-Action-Helpers-To-Implement-Re-Usable-Widgets.html
You can validate it on other page and redirect back after validation. Also, you can validate it through ajax.
What we usually do is that we send the form to different action and have dedicated form rendered in that actions view. If there is no error, user is redirected without noticing. If there is an error, the form is dispalyed in main content area with proper error messages. Usualy the problem is that the area of this form vidget is not big enough for good error message.
usually you post it to login page and if you fail you can redirect user back, set proper http header and display a error message