Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions hotfixes/email-templates/email-order-details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Order details table shown in emails.
*
* This matches version 3.0.0 of the email-order-details template.
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

$text_align = is_rtl() ? 'right' : 'left';

do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>

<?php if ( ! $sent_to_admin ) : ?>
<h2><?php printf( __( 'Order #%s', 'wc-api-dev' ), $order->get_order_number() ); ?></h2>
<?php else : ?>
<h2><a class="link" href="<?php echo esc_url( wc_api_dev_email_get_wpcom_order_link( $order->get_id() ) ); ?>"><?php printf( __( 'Order #%s', 'wc-api-dev' ), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ); ?>)</h2>
<?php endif; ?>

<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
<thead>
<tr>
<th class="td" scope="col" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Product', 'wc-api-dev' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Quantity', 'wc-api-dev' ); ?></th>
<th class="td" scope="col" style="text-align:<?php echo $text_align; ?>;"><?php _e( 'Price', 'wc-api-dev' ); ?></th>
</tr>
</thead>
<tbody>
<?php echo wc_get_email_order_items( $order, array(
'show_sku' => $sent_to_admin,
'show_image' => false,
'image_size' => array( 32, 32 ),
'plain_text' => $plain_text,
'sent_to_admin' => $sent_to_admin,
) ); ?>
</tbody>
<tfoot>
<?php
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
?><tr>
<th class="td" scope="row" colspan="2" style="text-align:<?php echo $text_align; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['label']; ?></th>
<td class="td" style="text-align:<?php echo $text_align; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['value']; ?></td>
</tr><?php
}
}
?>
</tfoot>
</table>

<?php do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text, $email ); ?>
36 changes: 36 additions & 0 deletions hotfixes/email-templates/plain/email-order-details.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* Order details table shown in emails.
*
* This matches version 2.5.0 of the email-order-details plain template.
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email );

echo strtoupper( sprintf( __( 'Order number: %s', 'wc-api-dev' ), $order->get_order_number() ) ) . "\n";
echo wc_format_datetime( $order->get_date_created() ) . "\n";
echo "\n" . wc_get_email_order_items( $order, array(
'show_sku' => $sent_to_admin,
'show_image' => false,
'image_size' => array( 32, 32 ),
'plain_text' => true,
'sent_to_admin' => $sent_to_admin,
) );

echo "==========\n\n";

if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
echo $total['label'] . "\t " . $total['value'] . "\n";
}
}

if ( $sent_to_admin ) {
echo "\n" . sprintf( __( 'View order: %s', 'wc-api-dev' ), wc_api_dev_email_get_wpcom_order_link( $order->get_id() ) ) . "\n";
}

do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text, $email );
44 changes: 44 additions & 0 deletions hotfixes/wc-api-dev-email-order-url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Provides a hotfix that points the admin order URL to WordPress.com instead of wp-admin.
*
* @since 0.8.3
*/

if ( ! defined( 'ABSPATH' ) ) {
exit;
}

function wc_api_dev_email_get_wpcom_order_link( $order_id ) {
$strip_http = '/.*?:\/\//i';
$site_slug = preg_replace( $strip_http, '', get_home_url() );
$site_slug = str_replace( '/', '::', $site_slug );

return 'https://wordpress.com/store/order/' . $site_slug . '/' . absint( $order_id );
}

function wc_api_dev_email_order_url( $markup, $sent_to_admin, $order ) {
$order_url = $sent_to_admin ? wc_api_dev_email_get_wpcom_order_link( $order->get_id() ) : $order->get_view_order_url();

$markup['url'] = $order_url;
$markup['potentialAction'] = array(
'@type' => 'ViewAction',
'name' => 'View Order',
'url' => $order_url,
'target' => $order_url,
);

return $markup;
}
add_filter( 'woocommerce_structured_data_order', 'wc_api_dev_email_order_url', 10, 3 );

function wc_api_dev_email_order_details_get_template( $located, $template_name, $args, $template_path, $default_path ) {
if ( 'emails/email-order-details.php' === $template_name ) {
return dirname( __FILE__ ) . '/email-templates/email-order-details.php';
}
if ( 'emails/plain/email-order-details.php' === $template_name ) {
return dirname( __FILE__ ) . '/email-templates/plain/email-order-details.php';
}
return $located;
}
add_filter( 'wc_get_template', 'wc_api_dev_email_order_details_get_template', 10, 5 );
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: automattic, woothemes
Tags: woocommerce, rest-api, api
Requires at least: 4.6
Tested up to: 4.8
Stable tag: 0.8.2
Stable tag: 0.8.3
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -25,6 +25,9 @@ This section describes how to install the plugin and get it working.

== Changelog ==

= 0.8.3 =
* Fix - Update order link in order details emails.

= 0.8.2 =
* Fix - Don't auto enable the PayPal payment method.

Expand Down
5 changes: 3 additions & 2 deletions wc-api-dev.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WooCommerce API Dev
* Plugin URI: https://woocommerce.com/
* Description: A feature plugin providing a bleeding edge version of the WooCommerce REST API.
* Version: 0.8.2
* Version: 0.8.3
* Author: Automattic
* Author URI: https://woocommerce.com
* Requires at least: 4.4
Expand Down Expand Up @@ -33,7 +33,7 @@ class WC_API_Dev {
/**
* Current version of the API plugin.
*/
const CURRENT_VERSION = '0.8.2';
const CURRENT_VERSION = '0.8.3';

/**
* Minimum version needed to run this version of the API.
Expand Down Expand Up @@ -131,6 +131,7 @@ public function includes() {
if ( defined( 'WC_API_DEV_ENABLE_HOTFIXES' ) && true === WC_API_DEV_ENABLE_HOTFIXES ) {
include_once( dirname( __FILE__ ) . '/hotfixes/wc-api-dev-jetpack-hotfixes.php' );
include_once( dirname( __FILE__ ) . '/hotfixes/wc-api-dev-email-site-title.php' );
include_once( dirname( __FILE__ ) . '/hotfixes/wc-api-dev-email-order-url.php' );
include_once( dirname( __FILE__ ) . '/hotfixes/wc-api-dev-cheque-defaults.php' );
include_once( dirname( __FILE__ ) . '/hotfixes/wc-api-dev-paypal-defaults.php' );
}
Expand Down