Forum Replies Created

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi, I love this plugin so much! Exactly what I want.
    But I have the same issue as lukelephant, please add this feature, thanks a lot.

    Thread Starter ive6830

    (@ive6830)

    Hi, I’ve copy the template to my child theme. But I couldn’t find where is the generated tracking info.
    I edited bst-shipment-tracking.php but it doesn’t seem to work. Could you give me an example, please?

    Thread Starter ive6830

    (@ive6830)

    Hi, I’ve copy the template to my child theme. But I couldn’t find where is the generated tracking info.
    I edited bst-shipment-tracking.php as followed. But it doesn’t seem to work. Could you give me an example, please?
    `<?php
    /**
    * Customer note email
    *
    * This template can be overridden by copying it to yourtheme/woocommerce/emails/bst-shipment-tracking.php.
    *
    * HOWEVER, on occasion WooCommerce will need to update template files, so this
    * plugin will need to update the template. In that case please copy the new files
    * to your theme to maintain compatibility.
    *
    * @package blazing-wooCommerce-tracking/templates/emails
    * @category Template
    * @since 1.0
    */

    if ( ! defined( ‘ABSPATH’ ) ) {
    exit;
    }

    /**
    * @hooked WC_Emails::email_header() Output the email header
    */
    do_action( ‘woocommerce_email_header’, $email_heading, $email ); ?>

    <p><?php _e( “For your reference, your order details are shown below.”, ‘woocommerce’ ); ?></p>

    <?php

    function display_tracking_info($order_id, $for_email = false)
    {

    // print_r($this->bst_fields);
    $values = array();
    foreach ($this->bst_fields as $field) {
    $values[$field[‘id’]] = get_post_meta($order_id, ‘_’ . $field[‘id’], true);
    if ($field[‘type’] == ‘date’ && $values[$field[‘id’]]) {
    $values[$field[‘id’]] = date_i18n(__(‘l jS F Y’, ‘wc_shipment_tracking’), $values[$field[‘id’]]);
    }
    }
    $values[‘bst_tracking_provider’] = get_post_meta($order_id, ‘_bst_tracking_provider’, true);
    $values[‘bst_shipping_postcode’] = get_post_meta( $order_id, ‘_shipping_postcode’, true );
    if ( !isset($values[‘bst_shipping_postcode’]) || trim($values[‘bst_shipping_postcode’]) === ” ) {
    $values[‘bst_shipping_postcode’] = get_post_meta( $order_id, ‘_billing_postcode’, true );
    }
    $values[‘bst_shipping_country’] = get_post_meta( $order_id, ‘_shipping_country’, true );
    if ( !isset($values[‘bst_shipping_country’]) || trim($values[‘bst_shipping_country’]) === ” ) {
    $values[‘bst_shipping_country’] = get_post_meta( $order_id, ‘_billing_country’, true );
    }

    if (!$values[‘bst_tracking_provider’])
    return;

    if (!$values[‘bst_tracking_number’])
    return;

    $provider_url = ”;
    if ( array_key_exists(‘bst_tracking_provider’, $values) && $values[‘bst_tracking_provider’] != “” ) {
    foreach ($this->couriers as &$c) {
    if ( $c[‘slug’] == $values[‘bst_tracking_provider’] ) {
    if ( array_key_exists(‘url’, $c) ) {
    $provider_url = str_replace( “{tracking_number}”, $values[‘bst_tracking_number’], $c[‘url’]);
    $provider_url = str_replace( “{shipping_postcode}”, $values[‘bst_shipping_postcode’], $provider_url);
    $provider_url = str_replace( “{shipping_country}”, $values[‘bst_shipping_country’], $provider_url);
    break;
    }
    }
    }
    }
    $provider_url = str_replace(‘ ‘, ”, $provider_url);

    $options = get_option(‘bst_option_name’);
    if (array_key_exists(‘track_message_1’, $options) && array_key_exists(‘track_message_2’, $options)) {
    $track_message_1 = $options[‘track_message_1’];
    $track_message_2 = $options[‘track_message_2’];
    } else {
    $track_message_1 = ‘Your order was shipped via ‘;
    $track_message_2 = ‘Tracking number is ‘;
    }

    //$required_fields_values = array();

    echo $track_message_1 . $values[‘bst_tracking_provider_name’] . ‘<br/>’ . $track_message_2 . ” ” . “” . $values[‘bst_tracking_number’] . “” . “<br />”;

    if (/*!$for_email && */ $this->use_track_button && $provider_url != ” ) {
    $btn = “<span>追蹤包裹</span>“;
    echo $btn;
    // $this->display_track_button($values[‘bst_tracking_provider’], $values[‘bst_tracking_number’], $required_fields_values);
    }

    //————————————————————————————-
    /*
    $tracking_provider = get_post_meta($order_id, ‘_bst_tracking_provider’, true);
    $tracking_number = get_post_meta($order_id, ‘_bst_tracking_number’, true);
    $tracking_provider_name = get_post_meta($order_id, ‘_bst_tracking_provider_name’, true);
    $date_shipped = get_post_meta($order_id, ‘_bst_tracking_shipdate’, true);

    if (!$tracking_provider)
    return;

    if (!$tracking_number)
    return;

    $provider_name = $tracking_provider_name;
    $provider_required_fields = explode(“,”, $tracking_required_fields);

    $date_shipped_str = ”;
    $postcode_str = ”;
    $account_str = ”;

    foreach ($provider_required_fields as $field) {
    if ($field == ‘tracking_ship_date’) {
    if ($date_shipped) {
    $date_shipped_str = ‘ ‘ . sprintf(__(‘on %s’, ‘wc_shipment_tracking’), date_i18n(__(‘l jS F Y’, ‘wc_shipment_tracking’), $date_shipped));
    }
    } else if ($field == ‘tracking_postal_code’) {
    if ($postcode) {
    $postcode_str = ‘ ‘ . sprintf(‘The postal code is %s.’, $postcode);
    }
    } else if ($field == ‘tracking_account_number’) {
    if ($account) {
    $account_str = ‘ ‘ . sprintf(‘The account is %s.’, $account);
    }
    }
    }

    $provider_name = ‘ ‘ . __(‘via’, ‘wc_shipment_tracking’) . ‘ ‘ . $provider_name . ‘‘;

    echo wpautop(sprintf(__(‘Your order was shipped%s%s. Tracking number is %s.%s%s’, ‘wc_shipment_tracking’), $date_shipped_str, $provider_name, $tracking_number, $postcode_str, $account_str));

    if (!$for_email && $this->use_track_button) {
    $this->display_track_button($tracking_provider, $tracking_number);
    }
    */

    }
    /**
    * @hooked WC_Emails::order_details() Shows the order details table.
    * @hooked WC_Emails::order_schema_markup() Adds Schema.org markup.
    * @since 2.5.0
    */
    do_action( ‘woocommerce_email_order_details’, $order, $sent_to_admin, $plain_text, $email );

    /**
    * @hooked WC_Emails::order_meta() Shows order meta data.
    */
    do_action( ‘woocommerce_email_order_meta’, $order, $sent_to_admin, $plain_text, $email );

    /**
    * @hooked WC_Emails::customer_details() Shows customer details
    * @hooked WC_Emails::email_address() Shows email address
    */
    do_action( ‘woocommerce_email_customer_details’, $order, $sent_to_admin, $plain_text, $email );

    /**
    * @hooked WC_Emails::email_footer() Output the email footer
    */
    do_action( ‘woocommerce_email_footer’, $email );

    Thread Starter ive6830

    (@ive6830)

    I use print_r($_product) to see the data in it, and find out that
    WC_Product_Simple Object has correct gallery image ids, as below: [gallery_image_ids] => Array ( [0] => 1174 [1] => 1175 [2] => 1176 )
    But WC_Product_Variation Object has no value in the array: [gallery_image_ids] => Array ( )

    I think it’s caused by Woocommerce upgrade. Because my localhost has totally different object structure of $_product.

    Does anyone know another way to get gallery image ids of variable product in cart page please?

    Thread Starter ive6830

    (@ive6830)

    I run my website on localhost now, if you don’t mind here is my code of single product’s variations:
    (I created a new product, and set variable S to 0 quantity, and it’s disappeared. I think the problem is that when I set the variable S to 0 quantity at WP backstage, it automatically regard as there is no variable S, so it didn’t show S in the front)

    <form class=”variations_form cart” method=”post” enctype=”multipart/form-data” data-product_id=”1066″ data-product_variations=”[{"variation_id":1069,"variation_is_visible":false,"variation_is_active":true,"is_purchasable":false,"display_price":0,"display_regular_price":0,"attributes":{"attribute_size":"L"},"image_src":"","image_link":"","image_title":"","image_alt":"","image_caption":"","image_srcset":"","image_sizes":"","price_html":"<span class=\"price\"><\/span>","availability_html":"<p class=\"stock out-of-stock\">This item is not available at this time due to pending orders.<\/p>","sku":"12345","weight":" kg","dimensions":"","min_qty":1,"max_qty":null,"backorders_allowed":false,"is_in_stock":false,"is_downloadable":false,"is_virtual":false,"is_sold_individually":"no","variation_description":""},{"variation_id":1070,"variation_is_visible":false,"variation_is_active":true,"is_purchasable":false,"display_price":0,"display_regular_price":0,"attributes":{"attribute_size":"M"},"image_src":"","image_link":"","image_title":"","image_alt":"","image_caption":"","image_srcset":"","image_sizes":"","price_html":"<span class=\"price\"><\/span>","availability_html":"<p class=\"stock out-of-stock\">This item is not available at this time due to pending orders.<\/p>","sku":"12345","weight":" kg","dimensions":"","min_qty":1,"max_qty":null,"backorders_allowed":false,"is_in_stock":false,"is_downloadable":false,"is_virtual":false,"is_sold_individually":"no","variation_description":""}]”>
    <table class=”variations” cellspacing=”0″>
    <tbody>
    <tr>
    <td class=”value”>
    <div><input type=”radio” name=”attribute_size” value=”M” id=”size_v_M”><label for=”size_v_M”>M</label></div><div><input type=”radio” name=”attribute_size” value=”L” id=”size_v_L”><label for=”size_v_L”>L</label></div>clear </td>
    </tr>
    </tbody>
    </table>
    <div class=”single_variation_wrap”>
    <div class=”woocommerce-variation single_variation” style=”display: none;”></div><div class=”woocommerce-variation-add-to-cart variations_button woocommerce-variation-add-to-cart-disabled”>
    <div class=”quantity”>
    <input type=”number” step=”1″ min=”” max=”” name=”quantity” value=”1″ title=”quantity” class=”input-text qty text” size=”4″ pattern=”[0-9]*” inputmode=”numeric”>
    </div>
    <button type=”submit” class=”single_add_to_cart_button button alt disabled wc-variation-selection-needed”>Add To Cart</button>
    <input type=”hidden” name=”add-to-cart” value=”1066″>
    <input type=”hidden” name=”product_id” value=”1066″>
    <input type=”hidden” name=”variation_id” class=”variation_id” value=””>
    </div>
    </div>
    </form>

    • This reply was modified 8 years, 3 months ago by ive6830.
    Thread Starter ive6830

    (@ive6830)

    Hi, I just found out something!
    I went to the WP backstage to change the quantity of variations S and M to 1, and the status set to “In stock”.
    Then I went to the product front-end page, yeah the variations S and M showed up. And then I checked out the S and M items, the variations S and M were still there at the product page (and being disabled).
    It just worked fine! Weird, isn’t it?
    I don’t know if it’s sort of a WooCommerce’s bug?
    Have any idea to fix that?

    Thread Starter ive6830

    (@ive6830)

    Hi, mantish. Thanks for your reply.
    I tried to test where the problem is by deactivating all my plugins (except WooCommerce) and switching to default Twenty Fifteen theme.
    But it’s still wrong (only show size L but missing S and M).
    So I’m not sure is it a WooCommerce’s bug or something I did wrong.
    And I found out a strange thing, this situation seems appears after I change the quantity of the product variable at WP Product Backstage Settings. But if the product is checkout and automatically set to “out out stock” status, the variable didn’t disappear.
    Another strange thing is that I tried to delete the product with this issue, and create a new product, it works fine at first. But after I change the new product’s SKU number and address URL to the same as the wrong product’s SKU and address URL, it gets wrong again.
    Do you have any other idea about how to find out where the problem is?
    Thanks.

    Thread Starter ive6830

    (@ive6830)

    Hi, Riaan. Thanks for your suggestion.
    Yes I forgot to mention that I use “WC Variations Radio Buttons” Plugin to change the dropdown button <select> of variations to radio buttons <input>.
    And I tried your brilliant way to test where the problem is by deactivating all my plugins (except WooCommerce) and switching to default Twenty Fifteen theme.
    But it’s still wrong (only show size L but missing S and M).
    And I found out a strange thing, this situation seems appears only when I change the quantity of the product variable at WP Product Backstage Settings. But if the product is checkout and automatically set to “out out stock” status, the variable didn’t disappear.
    Another strange thing is that I tried to delete the product with this issue, and create a new product, it works fine at first. But after I change the new product’s SKU number and address URL to the same as the wrong product’s SKU and address URL, it got wrong again.
    Do you have any other idea about how to find out where the problem is?
    Thanks.

Viewing 8 replies - 1 through 8 (of 8 total)