Plugin Directory

Changeset 2468156


Ignore:
Timestamp:
02/03/2021 05:18:59 PM (5 years ago)
Author:
appmaxplataforma
Message:

Ajustando a rotina que monta os itens do carrinho que são enviados via API; Tratando produtos do tipo Variável.

Location:
appmax-woocommerce/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • appmax-woocommerce/trunk/appmax-woocommerce.php

    r2421485 r2468156  
    33 * Plugin Name: AppMax WooCommerce
    44 * Description: Gateway de pagamento AppMax para WooCommerce.
    5  * Version: 2.0.31
     5 * Version: 2.0.32
    66 * License: GPLv2 or later
    77 * Author: AppMax Plataforma de Vendas Ltda
     
    2424    class AppMax_WC
    2525    {
    26         const VERSION = '2.0.31';
     26        const VERSION = '2.0.32';
    2727
    2828        /**
  • appmax-woocommerce/trunk/includes/class-awc-api.php

    r2393838 r2468156  
    246246
    247247        foreach ($items as $item => $values) {
    248 
    249             $product = wc_get_product( $values['product_id'] );
    250 
    251             $data = [
    252                 "sku" => $product->get_sku(),
    253                 "price" => (float) $product->get_price(),
    254                 "name" => $product->get_title(),
    255                 "qty" => $values['quantity'],
    256                 "description" => $product->get_description(),
    257                 "image" => get_the_post_thumbnail_url( $values['product_id'] ),
    258             ];
    259 
    260             array_push( $array_products, $data );
     248            array_push( $array_products, $this->awc_get_current_product( $values ) );
    261249        }
    262250
     
    337325        });
    338326    }
     327
     328    /**
     329     * @param $skuParentProduct
     330     * @param $values
     331     * @return array
     332     */
     333    private function awc_get_information_product_variation( $skuParentProduct, $values )
     334    {
     335        $variation = wc_get_product($values['variation_id']);
     336
     337        return [
     338            "sku" => "{$skuParentProduct}__{$variation->get_sku()}",
     339            "price" => (float) $variation->get_price(),
     340            "name" => $variation->get_name(),
     341            "qty" => $values['quantity'],
     342            "description" => $variation->get_description(),
     343            "image" => get_the_post_thumbnail_url( $values ),
     344        ];
     345    }
     346
     347    /**
     348     * @param WC_Product $product
     349     * @param $values
     350     * @return array
     351     */
     352    private function awc_get_information_product( WC_Product $product, $values )
     353    {
     354        return [
     355            "sku" => $product->get_sku(),
     356            "price" => (float) $product->get_price(),
     357            "name" => $product->get_title(),
     358            "qty" => $values['quantity'],
     359            "description" => $product->get_description(),
     360            "image" => get_the_post_thumbnail_url( $values['product_id'] ),
     361        ];
     362    }
     363
     364    /**
     365     * @param $values
     366     * @return array
     367     */
     368    private function awc_get_current_product( $values )
     369    {
     370        $product = wc_get_product( $values['product_id'] );
     371
     372        if (empty($values['variation_id']) && count($values['variation']) == 0) {
     373            return $this->awc_get_information_product( $product, $values );
     374        }
     375
     376        return $this->awc_get_information_product_variation( $product->get_sku(), $values );
     377
     378    }
    339379}
  • appmax-woocommerce/trunk/includes/class-awc-webhook-post.php

    r2421485 r2468156  
    286286            foreach ($bundle['products'] as $product) {
    287287
    288                 $product_woo_commerce = $this->awc_get_product_by_sku( $product['sku'] );
     288                $product_woo_commerce = $this->awc_get_product_by_sku( $this->awc_verify_sku_variation( $product['sku'] ) );
    289289
    290290                if ( $product_woo_commerce ) {
     
    330330    }
    331331
     332    private function awc_verify_sku_variation( $sku )
     333    {
     334        if (preg_match("/__/i", $sku)) {
     335            list($parent, $children) = explode("__", $sku);
     336            return $children;
     337        }
     338
     339        return $sku;
     340    }
     341
    332342    private function awc_get_order()
    333343    {
  • appmax-woocommerce/trunk/readme.txt

    r2421485 r2468156  
    44Requires at least: 4.0
    55Tested up to: 5.1
    6 Stable tag: 2.0.31
     6Stable tag: 2.0.32
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    117117== Changelog ==
    118118
     119= 2.0.32 =
     120
     121* Ajustando a rotina que monta os itens do carrinho que são enviados via API.
     122* Tratando produtos do tipo Variável.
     123
    119124= 2.0.31 =
    120125
Note: See TracChangeset for help on using the changeset viewer.