2
私はWoocommerceをダイナミックギャラリーPROで使用しています。製品ページのイメージは正常に機能し、管理者や顧客に送信された電子メールに製品イメージを表示することもできました。ただし、バリエーションイメージではなく、主な商品イメージが表示されます。ギャラリープラグインは、チェックアウトページの最初の画像を表示することを理解しています。Woocommerceのバリエーション商品画像は注文メールに表示されません
私は既に、Woocommerceのemail-order-details.phpで'$show_image'
をtrueにしています。
私は編集する必要があり、コードの文書は(私が思う)以下の通りである:以下のよう
<?php
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly
}
foreach ($items as $item_id => $item) :
$_product = apply_filters('woocommerce_order_item_product', $order->get_product_from_item($item), $item);
$item_meta = new WC_Order_Item_Meta($item, $_product);
if (apply_filters('woocommerce_order_item_visible', true, $item)) {
?>
<tr class="<?php echo esc_attr(apply_filters('woocommerce_order_item_class', 'order_item', $item, $order)); ?>">
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;"><?php
// Show title/image etc
**if ($show_image) {
echo apply_filters('woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ($_product->get_image_id() ? current(wp_get_attachment_image_src($_product->get_image_id(), 'thumbnail')) : wc_placeholder_img_src()) .'" alt="' . esc_attr__('Product Image', 'woocommerce') . '" height="' . esc_attr($image_size[1]) . '" width="' . esc_attr($image_size[0]) . '" style="vertical-align:middle; margin-right: 10px;" /></div>', $item);
}**
// Product name
echo apply_filters('woocommerce_order_item_name', $item['name'], $item, false);
// SKU
if ($show_sku && is_object($_product) && $_product->get_sku()) {
echo ' (#' . $_product->get_sku() . ')';
}
// allow other plugins to add additional product information here
do_action('woocommerce_order_item_meta_start', $item_id, $item, $order, $plain_text);
// Variation
if (! empty($item_meta->meta)) {
echo '<br/><small>' . nl2br($item_meta->display(true, true, '_', "\n")) . '</small>';
}
// File URLs
if ($show_download_links) {
$order->display_item_downloads($item);
}
// allow other plugins to add additional product information here
do_action('woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text);
?></td>
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters('woocommerce_email_order_item_quantity', $item['qty'], $item); ?></td>
<td class="td" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal($item); ?></td>
</tr>
<?php
}
if ($show_purchase_note && is_object($_product) && ($purchase_note = get_post_meta($_product->id, '_purchase_note', true))) : ?>
<tr>
<td colspan="3" style="text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wpautop(do_shortcode(wp_kses_post($purchase_note))); ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
それが画像を定義するギャラリーPROのファイルは以下のとおりです。
class WC_Dynamic_Gallery_Variations{
public static function wc_dgallery_change_variation() {
$product_id = (int) $_REQUEST['product_id'];
$variations = wp_unslash($_REQUEST['variations']);
ob_start();
if ($variations == '') {
WC_Gallery_Display_Class::wc_dynamic_gallery_display($product_id);
} else {
WC_Gallery_Display_Class::get_gallery_variations($product_id, $variations);
}
$result = ob_get_clean();
echo json_encode($result);
die();
}
public static function change_image_in_cart_page($product_image, $values, $cart_item_key) {
if (is_array($values) && isset($values['variation_id']) && $values['variation_id'] > 0) {
$variation_id = $values['variation_id'];
$dgallery_ids = WC_Dynamic_Gallery_Functions::get_gallery_ids($variation_id);
if (is_array($dgallery_ids) && count($dgallery_ids) > 0) {
// Use first image from variation gallery
$img_id = (int) array_shift($dgallery_ids);
$product_image = wp_get_attachment_image($img_id, 'shop_thumbnail');
}
} elseif (isset($values['product_id']) && $values['product_id'] > 0) {
$product_id = $values['product_id'];
// Don't change the image if product has featured image
if (has_post_thumbnail($product_id)) return $product_image;
$dgallery_ids = WC_Dynamic_Gallery_Functions::get_gallery_ids($product_id);
if (is_array($dgallery_ids) && count($dgallery_ids) > 0) {
// Use first image from variation gallery
$img_id = (int) array_shift($dgallery_ids);
$product_image = wp_get_attachment_image($img_id, 'shop_thumbnail');
}
}
return $product_image;
}
public static function wc_dgallery_variation_save_gallery_ids() {
if (isset($_POST['variation_id']) && $_POST['variation_id'] > 0 && isset($_POST['dgallery_ids'])) {
$variation_id = trim($_POST['variation_id']);
$dgallery_ids = array_filter(explode(',', trim($_POST['dgallery_ids'])));
update_post_meta($variation_id, '_product_image_gallery', implode(',', $dgallery_ids));
}
die();
}
public static function add_gallery_variation($loop, $variation_data, $variation) {
$global_wc_dgallery_activate = get_option(WOO_DYNAMIC_GALLERY_PREFIX.'activate');
$actived_d_gallery = get_post_meta($variation->post_parent, '_actived_d_gallery',true);
if ($actived_d_gallery == '' && $global_wc_dgallery_activate != 'no') {
$actived_d_gallery = 1;
}
$default_show_variation = get_option(WOO_DYNAMIC_GALLERY_PREFIX.'show_variation');
$show_variation = get_post_meta($variation->post_parent, '_wc_dgallery_show_variation',true);
if ($show_variation == '') {
$show_variation = $default_show_variation;
}
if ($show_variation == 1 || $show_variation == 'yes') {
$show_variation = 1 ;
}
?>
<div class="variations_dgallery_activated_panel_container a3-metabox-panel-wrap a3-dynamic-metabox-panel-wrap" style="<?php if (1 != $actived_d_gallery) { echo 'display: none;'; } ?> padding-left: 0px;">
<div class="a3-metabox-panel a3-metabox-wrapper">
<div id="variations_dgallery_panel" class="a3-metabox-items" style="<?php if (1 != $show_variation) { echo 'display: none;'; } ?>">
<div class="dgallery_images_container dgallery_variation_images_container a3-metabox-options-panel">
<h4 style="margin:0;">
<?php echo __('Variation Gallery', 'woo_dgallery'); ?>
<span class="a3_dg_variation_ajax_loader" style="display: none;"><img class="" src="<?php echo WOO_DYNAMIC_GALLERY_IMAGES_URL; ?>/ajax-loader.gif" /></span>
</h4>
<ul class="dgallery_images">
<?php
$variation_id = $variation->ID;
$dgallery_ids = WC_Dynamic_Gallery_Functions::get_gallery_ids($variation_id);
if (is_array($dgallery_ids) && count($dgallery_ids) > 0) {
foreach ($dgallery_ids as $img_id) {
$img_data = wp_get_attachment_image_src($img_id, 'thumbnail');
?>
<li class="image" data-attachment_id="<?php echo $img_id ; ?>">
<img class="image_item" src="<?php echo $img_data['0']; ?>" />
<ul class="actions">
<li><a href="#" class="delete dg_tips" data-tip="<?php echo __('Delete image', 'woo_dgallery'); ?>"><?php echo __('Delete image', 'woo_dgallery'); ?></a></li>
</ul>
</li>
<?php
}
}
?>
</ul>
<input type="hidden" class="dgallery_ids" data-variation-id="<?php echo $variation_id; ?>" value="<?php if ($dgallery_ids) echo esc_attr(implode(',', $dgallery_ids)); ?>" />
<p class="add_dgallery_images hide-if-no-js" style="margin: 10px 0px;">
<a href="#" data-choose="<?php _e('Add Images to Dynamic Gallery', 'woo_dgallery'); ?>" data-update="<?php _e('Add to gallery', 'woo_dgallery'); ?>" data-delete="<?php _e('Delete image', 'woo_dgallery'); ?>" data-text="<?php _e('Delete', 'woo_dgallery'); ?>"><?php _e('Add variation gallery images', 'woo_dgallery'); ?></a>
</p>
</div>
</div>
</div>
<?php
// Add an nonce field so we can check for it later.
//wp_nonce_field('a3_dynamic_variation_metabox_action', 'a3_dynamic_variation_metabox_nonce_field');
?>
<div style="clear: both;"></div>
</div>
<?php
} }
この精通誰か問題?私はプログラマーではありませんが、途中で多くを学びます。
は私にあなたの 'woocommerce /テンプレート/電子メール/メール・オーダー・items.php'コードを表示します。 – Noman