I need anything that, when a order is created, it sends in addition to the email that goes to the costumer, an email to one of my email accouts with only some information the customer inserted, such as:
Name
Surname
Street
Country etc.
How could I archive this?
Go to yoursite.com/wp-admin/admin.php?page=wc-settings&tab=email§ion=wc_email_new_order or from the dashboard:
Go to the WooCommerce sections and in that go to the Settings
In settings click on the Email tab and in that click on the New Order tab.
At the bottom of that page there is a button called: "Copy file to theme", click on that and then click on the "View Template" button. Replace the contents of the email from <?php do_action( 'woocommerce_email_header', $email_heading ); ?> down with:
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php echo $order->get_formatted_billing_address(); ?>
<?php if ( $order->billing_email ) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ( $order->billing_phone ) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
The above removes the order details and keeps the customers details.
Related
A client of mine uses a woocommerce webshop and asked me the following: i'm looking for a way to make the emailaddress of the customer in the customer details section of the admin-new-order email, a 'mailto:' link.
UPDATE
With your help so far i've found the correct file to edit (email-customer-details.php), but i'm not quite sure how to edit the file. So far it only states this:
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<ul>
<?php foreach ( $fields as $field ) : ?>
<li><strong><?php echo wp_kses_post( $field['label'] ); ?>:</strong> <span class="text"><?php echo wp_kses_post( $field['value'] ); ?></span></li>
<?php endforeach; ?>
</ul>
The output gives al list with the following:
Customer comment
Customer phonenumber
Customer e-mailadres
You can do that via changing the email-customer-details.php email template that you can find at : /plugins/woocommerce/templates/emails/
Just copy that file into your theme like your-theme/woocommerce/emails/email-customer-details.php and do the changes over there as you need.
Reference link
How can I display some custom error message when user clicks "place order" with card payment method selected, is redirected to the bank website, but then hits "cancel" and gets redirected back to WooCommerce thank you page?
The WooCommerce thank you page template code is summarized here (just in case I know how to add custom WooCommerce templates in my child theme):
if ( $order ) : ?>
<?php if ( $order->has_status( 'failed' ) ) : ?>
<p><?php _e( 'Unfortunately your order cannot be processed as the originating bank/merchant has declined your transaction.', 'woocommerce' ); ?></p>
<?php else : ?>
<p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), $order ); ?></p>
<?php endif; ?>
<?php do_action( 'woocommerce_thankyou_' . $order->payment_method, $order->id ); ?>
<?php do_action( 'woocommerce_thankyou', $order->id ); ?>
<?php else : ?>
<p><?php echo apply_filters( 'woocommerce_thankyou_order_received_text', __( 'Thank you. Your order has been received.', 'woocommerce' ), null ); ?></p>
<?php endif; ?>
Where does the bank payment cancelling case is located in this code? And how to display a custom message like "you cancelled bank payment, your order has been cancelled"?
function wdm_my_custom_message( $order_id ){
global $woocommerce;
$order=new WC_Order($order_id);
if ( $order->has_status( 'failed' ) ) {
$woocommerce->add_error( __( 'you cancelled bank payment, your order has been cancelled.', 'woocommerce' ) );
}
}
add_action( 'woocommerce_thankyou','wdm_my_custom_message',10,1);
this will help you to achieve your purpose.
I am having Issue in my checkout page. I am getting Two Place order button(click here). I tried to fix it in form-checkout.php even I checked in form-pay.php, in wp-content/themes/mytheme/woocommerce/checkout.
I checked in wordpress forum I got solution to remove two checkout button from cart page, there is no solution for my problem
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $woocommerce;
wc_print_notices();
do_action( 'woocommerce_before_checkout_form', $checkout );
// filter hook for include new pages inside the payment method
$get_checkout_url = apply_filters( 'woocommerce_get_checkout_url', WC()->cart->get_checkout_url() ); ?>
<form name="checkout" method="post" class="checkout" action="<?php echo esc_url( $get_checkout_url ); ?>">
<?php if ( sizeof( $checkout->checkout_fields ) > 0 ) : ?>
<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>
<div class="row" id="customer_details">
<div class="col-md-6">
<?php do_action( 'woocommerce_checkout_billing' ); ?>
</div>
<div class="col-md-6">
<?php do_action( 'woocommerce_checkout_shipping' ); ?>
</div>
</div>
<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>
<h3 id="order_review_heading"><?php _e( 'Your order', 'woocommerce' ); ?></h3>
<?php endif; ?>
<?php do_action( 'woocommerce_checkout_order_review' ); ?>
</form>
<?php do_action( 'woocommerce_after_checkout_form' ); ?>
Go to wp-content/themes/mytheme/woocommerce/checkout/view-order.php. In View-order.php remove id="payment" completle
This issue is because of theme version
Please check your configuration in your WordPress admin.
Woocommers->settings on the Payment Tab check your information details if you have miss an HTML tags.
I have experience on this when I customized or add some html tags on the details text area with closing "div" tag.
I am using TwentyEleven as my base theme which I have skinned.
In my Content.php file, the search results looks something like this
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
I am trying to pull the "Author" Meta key/value pairs to return in my search results along with the Post Title and Post Content like so:
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?>
<?php get_post_meta(get_the_ID(), _wpsc_author, true); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
Note the line:
<?php get_post_meta(get_the_ID(), _wpsc_author, true); ?>
Yet, this returns nothing?
I have read a fair amount on the topic of the_meta(), get_post_custom() etc, but nothing I am trying seems to have worked.
Would appreciate some insight?
EDIT:
Apologies, I wasn't too clear about the "Author" part.
Author is a custom field in the post_meta table along with "book type", book condition" published year" etc. It is not the Post Author.
Thanks
Do one thing just add echo before the function it will display the result and the last argument of the function will give you an array if it is set to false and a string if it set to true so change it according to your requirement
have you tried the_author_meta(); ?
You can use it like: the_author_meta('user_email')
Please note this function only works inside the loop... but there are ways around it, but they're gross.
available keys:
user_login
user_pass
user_nicename
user_email
user_url
user_registered
user_activation_key
user_status
display_name
nickname
first_name
last_name
description
jabber
aim
yim
user_level
user_firstname
user_lastname
user_description
rich_editing
comment_shortcuts
admin_color
plugins_per_page
plugins_last_view
ID
Howdy! I am looking for a way to list all of the image files in a posts' media library.
What I mean by this is if a file has been uploaded while creating or editing a post, is the file associated with the post in some way, and can I create a list from this data.
I think that the next_image_link() / previous_image_link(); template tag is as close as I have found.
I think that this should be close:
$query = 'SELECT * FROM `wp_posts`
WHERE `post_parent` = \''.$_GET['post_id'].'\'
AND `post_mime_type` = \'image/jpeg\'
ORDER BY `menu_order` ASC';
thanks.
In wordpress terminology, every image you uploaded to particular post is called attachment.
To list all attachment, you can use get_children() function:
$images =& get_children( 'post_type=attachment&post_mime_type=image&post_parent=10' );
$counter=0;
foreach( (array) $images as $attachment_id => $attachment )
{
$counter++;
echo "<a href='".wp_get_attachment_link( $attachment_id ) . "'>image $counter</a><br />";
}
The algorithm is something like that.
If you are looking for a plugin to manage image gallery, you can use attachments plugin,
http://wordpress.org/plugins/attachments/
It keeps the gallery separate and does not put the image gallery shortcodes in post content, thus providing you with full hold over image display in your post/page/custom post. You can also change the order of your images by just drag-n-drop
here is a sample code of how to retrieve your gallery images,
<?php $attachments = new Attachments( 'attachments' ); /* pass the instance name */ ?>
<?php if( $attachments->exist() ) : ?>
<h3>Attachments</h3>
<p>Total Attachments: <?php echo $attachments->total(); ?></p>
<ul>
<?php while( $attachments->get() ) : ?>
<li>
ID: <?php echo $attachments->id(); ?><br />
Type: <?php echo $attachments->type(); ?><br />
Subtype: <?php echo $attachments->subtype(); ?><br />
URL: <?php echo $attachments->url(); ?><br />
Image: <?php echo $attachments->image( 'thumbnail' ); ?><br />
Source: <?php echo $attachments->src( 'full' ); ?><br />
Size: <?php echo $attachments->filesize(); ?><br />
Title Field: <?php echo $attachments->field( 'title' ); ?><br />
Caption Field: <?php echo $attachments->field( 'caption' ); ?>
</li>
<?php endwhile; ?>
</ul>
<?php endif; ?>