Plugin Directory

Changeset 2371116


Ignore:
Timestamp:
08/28/2020 02:47:54 PM (5 years ago)
Author:
shoppingfeed
Message:

add ean support for variations

Location:
shopping-feed/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • shopping-feed/trunk/readme.txt

    r2357009 r2371116  
    22Contributors: ShoppingFeed, BeAPI
    33Tags: shoppingfeed, marketplace, woocommerce, woocommerce shoppingfeed, create woocommerce products shoppingfeed, products feed, generate shoppingfeed, amazon, Jet, Walmart, many marketplace, import orders
    4 Stable tag: 6.0.5
    5 Version: 6.0.5
     4Stable tag: 6.0.6
     5Version: 6.0.6
    66Requires PHP: 5.6
    77Requires at least: 5.2
     
    19196.0.4: fix permalink issue
    20206.0.5: correct attribute values
     216.0.6: add ean support for variations
    2122
    2223== Description ==
  • shopping-feed/trunk/shoppingfeed.php

    r2357009 r2371116  
    88 * Text Domain:     shopping-feed
    99 * Domain Path:     /languages
    10  * Version:         6.0.5
     10 * Version:         6.0.6
    1111 * Requires at least WP: 5.2
    1212 * Requires at least WooCommerce: 3.8 (3.9/4.0)
     
    2626}
    2727
    28 define( 'SF_VERSION', '6.0.5' );
     28define( 'SF_VERSION', '6.0.6' );
    2929define( 'SF_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    3030define( 'SF_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
  • shopping-feed/trunk/src/Feed/Generator.php

    r2339808 r2371116  
    229229                        ->setReference( $sf_product_variation['sku'] )
    230230                        ->setPrice( $sf_product_variation['price'] )
    231                         ->setQuantity( $sf_product_variation['quantity'] );
     231                        ->setQuantity( $sf_product_variation['quantity'] )
     232                        ->setGtin( $sf_product_variation['ean'] );
    232233
    233234                    if ( ! empty( $sf_product_variation['attributes'] ) ) {
  • shopping-feed/trunk/src/Products/Product.php

    r2357009 r2371116  
    9696     * @return string
    9797     */
    98     public function get_ean() {
    99         $ean_meta = ShoppingFeedHelper::wc_product_ean();
    100 
    101         if ( empty( $ean_meta ) ) {
    102             return '';
    103         }
    104 
    105         $ean = $this->product->get_meta( $ean_meta ) ? $this->product->get_meta( $ean_meta ) : '';
    106 
    107         return $ean;
     98    public function get_ean( $wc_product = false ) {
     99        $ean_meta_key = ShoppingFeedHelper::wc_product_ean();
     100
     101        if ( empty( $ean_meta_key ) ) {
     102            return '';
     103        }
     104
     105        if ( ! empty( $wc_product ) ) {
     106            return $wc_product->get_meta( $ean_meta_key ) ? $wc_product->get_meta( $ean_meta_key ) : '';
     107        }
     108
     109        return $this->product->get_meta( $ean_meta_key ) ? $this->product->get_meta( $ean_meta_key ) : '';
    108110    }
    109111
     
    309311            $variations = array();
    310312            foreach ( $wc_product_variations as $wc_product_variation ) {
    311                 $wc_product_variation = new \WC_Product_Variation( $wc_product_variation['variation_id'] );
     313                $wc_product_variation  = new \WC_Product_Variation( $wc_product_variation['variation_id'] );
    312314                $variation             = array();
    313315                $variation['sku']      = ( 'id' === $this->product_identifier ) ? $wc_product_variation->get_id() : $wc_product_variation->get_sku();
     316                $variation['ean']      = $this->get_ean( $wc_product_variation );
    314317                $variation['quantity'] = ! is_null( $wc_product_variation->get_stock_quantity() ) ? $wc_product_variation->get_stock_quantity() : ShoppingFeedHelper::get_default_product_quantity();
    315318                $variation['price']    = ! is_null( $wc_product_variation->get_regular_price() ) ? $wc_product_variation->get_regular_price() : $wc_product_variation->get_price();
Note: See TracChangeset for help on using the changeset viewer.