Plugin Directory

Changeset 3290493


Ignore:
Timestamp:
05/09/2025 12:37:07 PM (11 months ago)
Author:
simplercheckout
Message:

Version 1.1.7

Location:
simpler-checkout
Files:
2 added
34 edited
1 copied

Legend:

Unmodified
Added
Removed
  • simpler-checkout/tags/1.1.7/README.txt

    r3272319 r3290493  
    55Tested up to: 6.5
    66Requires PHP: 7.0
    7 Stable tag: 1.1.6
     7Stable tag: 1.1.7
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3535
    3636== Changelog ==
     37
     38== 1.1.7
     39Compat: [pw woocommerce gift cards] (https://wordpress.org/plugins/pw-woocommerce-gift-cards/)
    3740
    3841== 1.1.6
  • simpler-checkout/tags/1.1.7/includes/Compatibility/bundles.php

    r3272319 r3290493  
    99    return $value;
    1010}
     11
    1112add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_wc_pb_cart_item_is_bundled', 10, 2);
    1213
     
    1819    return $value;
    1920}
     21
    2022add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_wc_pb_cart_item_is_bundle_container', 10, 2);
    2123
    2224function simplerwc_compat_wc_pb_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    2325{
    24     if($bundle_type!='wc_pb') return $value;
    25 
    26     if (function_exists('wc_pb_get_bundled_cart_items') ){
     26    if ($bundle_type != 'wc_pb')
     27        return $value;
     28
     29    if (function_exists('wc_pb_get_bundled_cart_items')) {
    2730        $bundled_items = \wc_pb_get_bundled_cart_items($cart_item);
    2831        foreach ($bundled_items as $idx => $item) {
     
    3437    return $value;
    3538}
     39
    3640add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_wc_pb_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    3741
     
    4347    return $value;
    4448}
     49
    4550add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_wc_pb_product_is_bundle_container', 10, 2);
    4651
    4752function simplerwc_compat_wc_pb_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    4853{
    49     if($bundle_type!='wc_pb') return $value;
     54    if ($bundle_type != 'wc_pb')
     55        return $value;
    5056
    5157    if (is_a($product, 'WC_Product_Bundle') && class_exists('WC_PB_DB')) {
     
    6571    return $value;
    6672}
     73
    6774add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_wc_pb_get_all_products_linked_to_the_bundle_product', 10, 3);
    6875
    6976function simplerwc_compat_wc_pb_add_simpler_bundle_to_cart($value, $simpler_item)
    7077{
    71     if($simpler_item->get_bundle_type()!='wc_pb') return $value;
    72 
    73     if (!class_exists('WC_PB_DB')) return $value;
     78    if ($simpler_item->get_bundle_type() != 'wc_pb')
     79        return $value;
     80
     81    if (!class_exists('WC_PB_DB'))
     82        return $value;
    7483
    7584    // the final bundle configuration to be added to cart
     
    7887    // get bundle configurations
    7988    $bundled = \WC_PB_DB::query_bundled_items(array(
    80         'return'    => 'id=>product_id',
     89        'return' => 'id=>product_id',
    8190        'bundle_id' => array($simpler_item->get_product_id())
    8291    ));
     
    125134    );
    126135}
     136
    127137function simplerwc_compat_wc_pb_construct_variation_configuration($bundle, $product)
    128138{
     
    138148    return $c;
    139149}
     150
    140151add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_wc_pb_add_simpler_bundle_to_cart', 10, 2);
    141152
    142 function simplerwc_compat_wc_pb_get_product_type_of_the_bundle($value,$bundle_type)
    143 {
    144     if($bundle_type=='wc_pb') return 'bundle';
    145     return $value;
    146 }
     153function simplerwc_compat_wc_pb_get_product_type_of_the_bundle($value, $bundle_type)
     154{
     155    if ($bundle_type == 'wc_pb')
     156        return 'bundle';
     157    return $value;
     158}
     159
    147160add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_wc_pb_get_product_type_of_the_bundle', 10, 2);
    148161
    149 function simplerwc_compat_wc_pb_get_bundle_type_of_the_product($value,$product)
    150 {
    151     if($value) return $value;
     162function simplerwc_compat_wc_pb_get_bundle_type_of_the_product($value, $product)
     163{
     164    if ($value)
     165        return $value;
    152166    if (is_a($product, 'WC_Product_Bundle') && class_exists('WC_PB_DB')) {
    153167        return 'wc_pb';
     
    155169    return $value;
    156170}
     171
    157172add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_wc_pb_get_bundle_type_of_the_product', 10, 2);
    158 
    159 
    160173
    161174// WPC Smart Bundles
    162175function simplerwc_compat_woosb_cart_item_is_bundled($value, $cart_item)
    163176{
    164     if (array_key_exists('woosb_parent_id',$cart_item)) {
     177    if (array_key_exists('woosb_parent_id', $cart_item)) {
    165178        return true;
    166179    }
    167180    return $value;
    168181}
     182
    169183add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_woosb_cart_item_is_bundled', 10, 2);
    170184
    171185function simplerwc_compat_woosb_cart_item_is_bundle_container($value, $cart_item)
    172186{
    173     if (isset($cart_item['woosb_ids']) && !empty($cart_item['woosb_ids'])){
     187    if (isset($cart_item['woosb_ids']) && !empty($cart_item['woosb_ids'])) {
    174188        return 'woosb';
    175189    }
    176190    return $value;
    177191}
     192
    178193add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_woosb_cart_item_is_bundle_container', 10, 2);
    179194
    180195function simplerwc_compat_woosb_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    181196{
    182     if($bundle_type!='woosb') return $value;
     197    if ($bundle_type != 'woosb')
     198        return $value;
    183199
    184200    $bundled_items = [];
    185201    $bundle_ids = explode(',', $cart_item['woosb_ids']);
    186    
     202
    187203    foreach ($bundle_ids as $id) {
    188204        foreach ($cart->get_cart_contents() as $item) {
     
    195211    return $bundled_items;
    196212}
     213
    197214add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_woosb_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    198215
    199216function simplerwc_compat_woosb_product_is_bundle_container($value, $product)
    200217{
    201     if (is_a( $product, 'WC_Product_Woosb' )) {
     218    if (is_a($product, 'WC_Product_Woosb')) {
    202219        return 'woosb';
    203220    }
    204221    return $value;
    205222}
     223
    206224add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_woosb_product_is_bundle_container', 10, 2);
    207225
    208226function simplerwc_compat_woosb_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    209227{
    210     if($bundle_type!='woosb') return $value;
    211 
    212     if (is_a( $product, 'WC_Product_Woosb' )) {
     228    if ($bundle_type != 'woosb')
     229        return $value;
     230
     231    if (is_a($product, 'WC_Product_Woosb')) {
    213232        $bundle_items = $product->get_meta('woosb_ids');
    214233        if (is_array($bundle_items)) {
     
    226245    return $value;
    227246}
     247
    228248add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_woosb_get_all_products_linked_to_the_bundle_product', 10, 3);
    229249
    230250function simplerwc_compat_woosb_add_simpler_bundle_to_cart($value, $simpler_item)
    231251{
    232     if($simpler_item->get_bundle_type()!='woosb') return $value;
    233 
    234     if (!class_exists('WPCleverWoosb')) return $value;
     252    if ($simpler_item->get_bundle_type() != 'woosb')
     253        return $value;
     254
     255    if (!class_exists('WPCleverWoosb'))
     256        return $value;
    235257
    236258    $WPCleverWoosb = new \WPCleverWoosb;
    237259    $cart_data = apply_filters('simplerwc_get_cart_item_data', [], $simpler_item);
    238        
    239     $product_id = $simpler_item->get_product_id(); 
    240     $quantity = $simpler_item->get_quantity(); 
    241     $variation_id = NULL; 
    242     $variation = $simpler_item->get_attributes_array(); 
    243 
    244     $cart_item_data = $WPCleverWoosb->add_cart_item_data($cart_data,$product_id);
    245     if(isset($cart_item_data['woosb_ids'])){
     260
     261    $product_id = $simpler_item->get_product_id();
     262    $quantity = $simpler_item->get_quantity();
     263    $variation_id = NULL;
     264    $variation = $simpler_item->get_attributes_array();
     265
     266    $cart_item_data = $WPCleverWoosb->add_cart_item_data($cart_data, $product_id);
     267    if (isset($cart_item_data['woosb_ids'])) {
    246268        $new_woosb_ids = [];
    247         $woosb_ids = explode(',',$cart_item_data['woosb_ids']);
    248         foreach($woosb_ids as $woosb_id){
    249             list($pid,$pkey,$pqty) = explode('/',$woosb_id);
    250             foreach($simpler_item->get_bundled() as $b_item){
    251                 if($pid == $b_item['product_id']){
     269        $woosb_ids = explode(',', $cart_item_data['woosb_ids']);
     270        foreach ($woosb_ids as $woosb_id) {
     271            list($pid, $pkey, $pqty) = explode('/', $woosb_id);
     272            foreach ($simpler_item->get_bundled() as $b_item) {
     273                if ($pid == $b_item['product_id']) {
    252274                    $pqty = $b_item['quantity'];
    253                     $new_woosb_id = implode('/',[$pid,$pkey,$pqty]);
    254                     $new_woosb_ids[]=$new_woosb_id;
     275                    $new_woosb_id = implode('/', [$pid, $pkey, $pqty]);
     276                    $new_woosb_ids[] = $new_woosb_id;
    255277                }
    256278            }
    257279        }
    258         $cart_item_data['woosb_ids'] = implode(',',$new_woosb_ids);
     280        $cart_item_data['woosb_ids'] = implode(',', $new_woosb_ids);
    259281    }
    260282
    261283    $cart_item_key = WC()->cart->add_to_cart(
    262         $product_id, 
    263         $quantity,   
    264         $variation_id, 
    265         $variation, 
    266         $cart_item_data 
     284        $product_id,
     285        $quantity,
     286        $variation_id,
     287        $variation,
     288        $cart_item_data
    267289    );
    268    
    269     $WPCleverWoosb->add_to_cart($cart_item_key, $product_id, $quantity,null,[],$cart_item_data);
     290
     291    $WPCleverWoosb->add_to_cart($cart_item_key, $product_id, $quantity, null, [], $cart_item_data);
    270292    return $cart_item_key;
    271293}
     294
    272295add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_woosb_add_simpler_bundle_to_cart', 10, 2);
    273296
    274297function simplerwc_compat_woosb_before_create_quoted_product($lineItem)
    275298{
    276     if(isset($lineItem['woosb_price'])){
     299    if (isset($lineItem['woosb_price'])) {
    277300        $lineItem['line_total'] = $lineItem['woosb_price'];
    278301        $lineItem['line_subtotal'] = $lineItem['woosb_price'];
    279302    }
    280     if(isset($lineItem['woosb_parent_id'])){
     303    if (isset($lineItem['woosb_parent_id'])) {
    281304        $lineItem['line_total'] = 0;
    282305        $lineItem['line_subtotal'] = 0;
     
    284307    return $lineItem;
    285308}
     309
    286310add_filter('simplerwc_before_create_quoted_product', 'simplerwc_compat_woosb_before_create_quoted_product', 10, 1);
    287311
    288 function simplerwc_compat_woosb_get_product_type_of_the_bundle($value,$bundle_type)
    289 {
    290     if($bundle_type=='woosb') return 'bundle';
    291     return $value;
    292 }
     312function simplerwc_compat_woosb_get_product_type_of_the_bundle($value, $bundle_type)
     313{
     314    if ($bundle_type == 'woosb')
     315        return 'bundle';
     316    return $value;
     317}
     318
    293319add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_woosb_get_product_type_of_the_bundle', 10, 2);
    294320
    295 function simplerwc_compat_woosb_get_bundle_type_of_the_product($value,$product)
    296 {
    297     if($value) return $value;
    298     if (is_a( $product, 'WC_Product_Woosb' )) {
     321function simplerwc_compat_woosb_get_bundle_type_of_the_product($value, $product)
     322{
     323    if ($value)
     324        return $value;
     325    if (is_a($product, 'WC_Product_Woosb')) {
    299326        return 'woosb';
    300327    }
    301328    return $value;
    302329}
     330
    303331add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_woosb_get_bundle_type_of_the_product', 10, 2);
    304 
    305 
    306332
    307333// WPC Frequently Brought Together
    308334function simplerwc_compat_woobt_cart_item_is_bundled($value, $cart_item)
    309335{
    310     if (array_key_exists('woobt_parent_id',$cart_item)) {
     336    if (array_key_exists('woobt_parent_id', $cart_item)) {
    311337        return true;
    312338    }
    313339    return $value;
    314340}
     341
    315342add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_woobt_cart_item_is_bundled', 10, 2);
    316343
    317344function simplerwc_compat_woobt_cart_item_is_bundle_container($value, $cart_item)
    318345{
    319     if (isset($cart_item['woobt_ids']) && !empty($cart_item['woobt_ids'])){
     346    if (isset($cart_item['woobt_ids']) && !empty($cart_item['woobt_ids'])) {
    320347        return 'woobt';
    321348    }
    322349    return $value;
    323350}
     351
    324352add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_woobt_cart_item_is_bundle_container', 10, 2);
    325353
    326354function simplerwc_compat_woobt_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    327355{
    328     if($bundle_type!='woobt') return $value;
     356    if ($bundle_type != 'woobt')
     357        return $value;
    329358
    330359    $bundled_items = [];
    331360    $bundle_ids = explode(',', $cart_item['woobt_ids']);
    332    
     361
    333362    foreach ($bundle_ids as $bundle_line) {
    334         list($id,$code,$qty) = explode('/',$bundle_line);
     363        list($id, $code, $qty) = explode('/', $bundle_line);
    335364        foreach ($cart->get_cart_contents() as $item) {
    336             if ($item['product_id'] == $id && isset($item['woobt_parent_id']) && $item['woobt_parent_id']==$cart_item['product_id']) {
     365            if ($item['product_id'] == $id && isset($item['woobt_parent_id']) && $item['woobt_parent_id'] == $cart_item['product_id']) {
    337366                $bundled_items[] = $item;
    338367                break;
     
    342371    return $bundled_items;
    343372}
     373
    344374add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_woobt_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    345375
     
    348378    $linked_products = get_post_meta($product->get_id(), 'woobt_ids', true);
    349379
    350     if (empty($linked_products)) return $value;
    351    
     380    if (empty($linked_products))
     381        return $value;
     382
    352383    return 'woobt';
    353384}
     385
    354386add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_woobt_product_is_bundle_container', 10, 2);
    355387
    356388function simplerwc_compat_woobt_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    357389{
    358     if($bundle_type!='woobt') return $value;
     390    if ($bundle_type != 'woobt')
     391        return $value;
    359392
    360393    $linked_products = get_post_meta($product->get_id(), 'woobt_ids', true);
    361394
    362     if (empty($linked_products)) return $value;
     395    if (empty($linked_products))
     396        return $value;
    363397
    364398    $linked_products = maybe_unserialize($linked_products);
    365    
     399
    366400    foreach ($linked_products as $key => $item) {
    367401        if (isset($item['id'])) {
    368402            $product = wc_get_product($item['id']);
    369403            if ($product) {
    370                 $value[]=$product;
    371             }
    372         }
    373     }
    374     return $value;
    375 }
     404                $value[] = $product;
     405            }
     406        }
     407    }
     408    return $value;
     409}
     410
    376411add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_woobt_get_all_products_linked_to_the_bundle_product', 10, 3);
    377412
    378413function simplerwc_compat_woobt_add_simpler_bundle_to_cart($value, $simpler_item)
    379414{
    380     if($simpler_item->get_bundle_type()!='woobt') return $value;
     415    if ($simpler_item->get_bundle_type() != 'woobt')
     416        return $value;
    381417
    382418    $main_product_metadata = apply_filters('simplerwc_get_cart_item_data', [], $simpler_item);
    383    
    384     $main_product_id = $simpler_item->get_product_id(); 
     419
     420    $main_product_id = $simpler_item->get_product_id();
    385421    $main_product_cart_key = WC()->cart->add_to_cart(
    386         $main_product_id, 
    387         $simpler_item->get_quantity(),   
    388         null, 
    389         $simpler_item->get_attributes_array(), 
     422        $main_product_id,
     423        $simpler_item->get_quantity(),
     424        null,
     425        $simpler_item->get_attributes_array(),
    390426        $main_product_metadata
    391427    );
    392428    $value = $main_product_cart_key;
    393    
     429
    394430    if (class_exists('WPCleverWoobt')) {
    395431        $WPCleverWoobt = new \WPCleverWoobt;
     
    397433        $main_product_metadata['woobt_ids'] = '';
    398434        $ids = [];
    399         $linked_products = $WPCleverWoobt->get_product_items( $main_product_id );
    400         foreach ($linked_products as $linked_key => $linked_product){
    401             foreach($simpler_item->get_bundled() as $simpler_bundled_item){
    402                 if($simpler_bundled_item['product_id'] == $linked_product['id']){
    403                     $ids[] = $simpler_bundled_item['product_id'].'/'.$linked_key.'/'.$simpler_bundled_item['quantity'];
     435        $linked_products = $WPCleverWoobt->get_product_items($main_product_id);
     436        foreach ($linked_products as $linked_key => $linked_product) {
     437            foreach ($simpler_item->get_bundled() as $simpler_bundled_item) {
     438                if ($simpler_bundled_item['product_id'] == $linked_product['id']) {
     439                    $ids[] = $simpler_bundled_item['product_id'] . '/' . $linked_key . '/' . $simpler_bundled_item['quantity'];
    404440                }
    405441            }
    406442        }
    407         $main_product_metadata['woobt_ids']=implode(',',$ids);
     443        $main_product_metadata['woobt_ids'] = implode(',', $ids);
    408444        $WPCleverWoobt->add_to_cart(
    409             $main_product_cart_key, 
    410             $main_product_id, 
     445            $main_product_cart_key,
     446            $main_product_id,
    411447            $simpler_item->get_quantity(),
    412448            null,
    413             $simpler_item->get_attributes_array(), 
     449            $simpler_item->get_attributes_array(),
    414450            $main_product_metadata
    415451        );
     
    419455    return $value;
    420456}
     457
    421458add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_woobt_add_simpler_bundle_to_cart', 10, 2);
    422459
    423 function simplerwc_compat_woobt_get_product_type_of_the_bundle($value,$bundle_type)
    424 {
    425     return $value;
    426 }
     460function simplerwc_compat_woobt_get_product_type_of_the_bundle($value, $bundle_type)
     461{
     462    return $value;
     463}
     464
    427465add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_woobt_get_product_type_of_the_bundle', 10, 2);
    428466
    429 function simplerwc_compat_woobt_get_bundle_type_of_the_product($value,$product)
    430 {
    431     if($value) return $value;
     467function simplerwc_compat_woobt_get_bundle_type_of_the_product($value, $product)
     468{
     469    if ($value)
     470        return $value;
    432471    $linked_products = get_post_meta($product->get_id(), 'woobt_ids', true);
    433     if (!empty($linked_products)) return 'woobt';
    434     return $value;
    435 }
     472    if (!empty($linked_products))
     473        return 'woobt';
     474    return $value;
     475}
     476
    436477add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_woobt_get_bundle_type_of_the_product', 10, 2);
    437 
    438 
    439478
    440479// WC Linked products
    441480function simplerwc_compat_woocommerce_cart_item_is_bundled($value, $cart_item)
    442481{
    443     if (array_key_exists('bundle_sell_of',$cart_item)) {
     482    if (array_key_exists('bundle_sell_of', $cart_item)) {
    444483        return true;
    445484    }
    446485    return $value;
    447486}
     487
    448488add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_woocommerce_cart_item_is_bundled', 10, 2);
    449489
    450490function simplerwc_compat_woocommerce_cart_item_is_bundle_container($value, $cart_item)
    451491{
    452     if (isset($cart_item['bundle_sells']) && !empty($cart_item['bundle_sells'])){
     492    if (isset($cart_item['bundle_sells']) && !empty($cart_item['bundle_sells'])) {
    453493        return 'woocommerce';
    454494    }
    455495    return $value;
    456496}
     497
    457498add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_woocommerce_cart_item_is_bundle_container', 10, 2);
    458499
    459500function simplerwc_compat_woocommerce_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    460501{
    461     if($bundle_type!='woocommerce') return $value;
     502    if ($bundle_type != 'woocommerce')
     503        return $value;
    462504
    463505    $bundled_items = [];
    464     $cross_sell_items = $cart_item["bundle_sells"] ?? [];
     506    $cross_sell_items = $cart_item['bundle_sells'] ?? [];
    465507    foreach ($cross_sell_items as $id) {
    466508        $bundled_items[] = $cart->get_cart_item($id);
     
    468510    return $bundled_items;
    469511}
     512
    470513add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_woocommerce_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    471514
     
    474517    $linked_products = get_post_meta($product->get_id(), 'bundle_sells', true);
    475518
    476     if (empty($linked_products)) return $value;
    477    
    478     return $value;
    479 }
     519    if (empty($linked_products))
     520        return $value;
     521
     522    return $value;
     523}
     524
    480525add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_woocommerce_product_is_bundle_container', 10, 2);
    481526
    482527function simplerwc_compat_woocommerce_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    483528{
    484     if($bundle_type!='woocommerce') return $value;
    485 
    486     return $value;
    487 }
     529    if ($bundle_type != 'woocommerce')
     530        return $value;
     531
     532    return $value;
     533}
     534
    488535add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_woocommerce_get_all_products_linked_to_the_bundle_product', 10, 3);
    489536
    490537function simplerwc_compat_woocommerce_add_simpler_bundle_to_cart($value, $simpler_item)
    491538{
    492     if($simpler_item->get_bundle_type()!='woocommerce') return $value;
     539    if ($simpler_item->get_bundle_type() != 'woocommerce')
     540        return $value;
    493541
    494542    $main_product_cart_key = \WC()->cart->add_to_cart(
     
    515563    return $main_product_cart_key;
    516564}
     565
    517566add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_woocommerce_add_simpler_bundle_to_cart', 10, 2);
    518567
    519 function simplerwc_compat_woocommerce_get_product_type_of_the_bundle($value,$bundle_type)
    520 {
    521     return $value;
    522 }
     568function simplerwc_compat_woocommerce_get_product_type_of_the_bundle($value, $bundle_type)
     569{
     570    return $value;
     571}
     572
    523573add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_woocommerce_get_product_type_of_the_bundle', 10, 2);
    524574
    525 function simplerwc_compat_woocommerce_get_bundle_type_of_the_product($value,$product)
    526 {
    527     if($value) return $value;
    528     return 'woocommerce';
    529 }
     575function simplerwc_compat_woocommerce_get_bundle_type_of_the_product($value, $product)
     576{
     577    if ($value)
     578        return $value;
     579    return 'woocommerce';
     580}
     581
    530582add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_woocommerce_get_bundle_type_of_the_product', 11, 2);
  • simpler-checkout/tags/1.1.7/includes/Compatibility/cod.php

    r3272319 r3290493  
    66use Simpler\Models\Quotation;
    77
    8 
    98/**
    109 * @param  Quotation  $quotation
     
    1312 * @return PaymentMethod[]
    1413 */
    15 function simplerwc_compat_wc_smart_cod_quote(array $paymentMethods, Quotation $quotation) {
    16 
     14function simplerwc_compat_wc_smart_cod_quote(array $paymentMethods, Quotation $quotation)
     15{
    1716    $shippingMethod = $quotation->get_shipping_rate();
    1817
    19     if(!$shippingMethod) {
     18    if (!$shippingMethod) {
    2019        return $paymentMethods;
    2120    }
    2221
    23     if(!defined('DOING_AJAX')) define('DOING_AJAX',true);
     22    if (!defined('DOING_AJAX'))
     23        define('DOING_AJAX', true);
    2424    $availablePaymentMethods = WC()->payment_gateways->get_available_payment_gateways();
    25    
     25
    2626    $codCost = 0;
    27     if (isset($availablePaymentMethods['cod']) ) {
    28         if ($availablePaymentMethods['cod'] instanceof \WC_Smart_COD_Admin ) {
     27    if (isset($availablePaymentMethods['cod'])) {
     28        if ($availablePaymentMethods['cod'] instanceof \WC_Smart_COD_Admin) {
    2929            $smartCod = new \WC_Smart_COD_Public('wc-smart-cod');
    3030            $smartCod->init_wsc_settings();
    31             if(!$smartCod->has_cod_available()){
     31            if (!$smartCod->has_cod_available()) {
    3232                return $paymentMethods;
    3333            }
    34             $codCost = $smartCod->apply_smart_cod_fees(WC()->cart,false);
    35             if (isset($availablePaymentMethods['cod']->settings['extra_fee_tax']) && $availablePaymentMethods['cod']->settings['extra_fee_tax']=='enable') {
    36                 $taxes = \wc_array_merge_recursive_numeric([],\WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false));
     34            $codCost = $smartCod->apply_smart_cod_fees(WC()->cart, false);
     35            if (isset($availablePaymentMethods['cod']->settings['extra_fee_tax']) && $availablePaymentMethods['cod']->settings['extra_fee_tax'] == 'enable') {
     36                $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false));
    3737                if (!empty($taxes)) {
    3838                    $codCost += array_sum($taxes);
     
    5858add_filter('simplerwc_quotation_payment_method', 'simplerwc_compat_wc_smart_cod_quote', 10, 2);
    5959
    60 
    6160/**
    6261 * @param  Closure[]     $closures
     
    6867{
    6968    if (
    70         !($paymentMethod = $orderRequest->get_order()->get_payment_method())
    71         || $paymentMethod->getType() != PaymentMethod::COD
    72         || !class_exists('Wc_Smart_Cod_Admin')
     69        !($paymentMethod = $orderRequest->get_order()->get_payment_method()) ||
     70        $paymentMethod->getType() != PaymentMethod::COD ||
     71        !class_exists('Wc_Smart_Cod_Admin')
    7372    ) {
    7473        return $closures;
  • simpler-checkout/tags/1.1.7/includes/Compatibility/free-gifts.php

    r3272319 r3290493  
    1818    }
    1919}
     20
    2021add_action('simplerwc_after_add_to_cart', 'simplerwc_fgf_after_add_to_cart');
    21 
    22 
    2322
    2423// iThemeland Free Gifts : https://ithemelandco.com/plugins/free-gifts-for-woocommerce/
     
    4443add_filter('simplerwc_button_should_ignore_cart_item', 'simplerwc_compat_ithemeland_free_gifts_ignore', 10, 2);
    4544
    46 
    47 
    4845// BOGO https://woocommerce.com/products/buy-one-get-one-free/
    4946function simplerwc_compat_bogof_free_gifts_ignore($value, $cart_item)
     
    5451    return $value;
    5552}
     53
    5654add_filter('simplerwc_button_should_ignore_cart_item', 'simplerwc_compat_bogof_free_gifts_ignore', 10, 2);
    57 
    58 
    5955
    6056// Asana [WooCommerce Dynamic Pricing and Discounts] https://www.asanaplugins.com/product/woocommerce-dynamic-pricing-and-discounts-plugin/
     
    6662    return $value;
    6763}
     64
    6865add_filter('simplerwc_button_should_ignore_cart_item', 'simplerwc_compat_asana_wcdpd_free_gifts_ignore', 10, 2);
    69 
    70 
    7166
    7267// Pricepep [WooCommerce Dynamic Pricing, Discounts & Fees] https://codecanyon.net/item/woocommerce-dynamic-pricing-discounts/7119279
     
    7570    add_filter('rp_wcdpd_request_is_product_feed', '__return_true', 10, 0);
    7671}
     72
    7773add_action('simplerwc_product_controller_request_before', 'simplerwc_rp_wcdpd_set_is_product_feed', 1, 0);
  • simpler-checkout/tags/1.1.7/includes/Compatibility/gift-wrap.php

    r3272319 r3290493  
    11<?php
    22
    3 use Simpler\Models\Money;
    43use Simpler\Models\GiftWrapAddon;
    54use Simpler\Models\GiftWrapOption;
     5use Simpler\Models\Money;
    66
    77// Gift Wrapping for WooCommerce https://wordpress.com/plugins/gift-wrapping-for-woocommerce
    88function simplerwc_compat_quote_tgpc_gift_wrapping_for_woocommerce($value, $quotation)
    99{
    10     if ( ! class_exists( 'Tgpc_Wc_Gift_Wrap' ) ) {
     10    if (!class_exists('Tgpc_Wc_Gift_Wrap')) {
    1111        return $value;
    1212    }
    1313
    14     if ( get_option( 'tgpc_gift_wrapper_enabled' ) !== 'yes' ){
     14    if (get_option('tgpc_gift_wrapper_enabled') !== 'yes') {
    1515        return $value;
    1616    }
    1717    $giftWrapAddon = new GiftWrapAddon();
    18     $giftWrapOption = new GiftWrapOption("1");
     18    $giftWrapOption = new GiftWrapOption('1');
    1919
    20     $fee_cost   = (float) apply_filters( 'tgpc_wc_gift_wrapper_cost', get_option( 'tgpc_gift_wrapper_cost', 0 ) );
     20    $fee_cost = (float) apply_filters('tgpc_wc_gift_wrapper_cost', get_option('tgpc_gift_wrapper_cost', 0));
    2121    $tax_cost = 0;
    2222    $net_cost = $fee_cost;
    23    
    24     $is_taxable = get_option( 'tgpc_gift_wrapper_cost_tax_status' ) === 'yes';
    25     $tax_class  = get_option( 'tgpc_gift_wrapper_tax_class', '' );
     23
     24    $is_taxable = get_option('tgpc_gift_wrapper_cost_tax_status') === 'yes';
     25    $tax_class = get_option('tgpc_gift_wrapper_tax_class', '');
    2626    if ($is_taxable) {
    27         $taxes = \wc_array_merge_recursive_numeric([],\WC_Tax::calc_tax($fee_cost, $tax_class, false));
     27        $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($fee_cost, $tax_class, false));
    2828        if (!empty($taxes)) {
    2929            $tax_cost = array_sum($taxes);
     
    3232    }
    3333
    34     if ( $fee_cost ) {
     34    if ($fee_cost) {
    3535        $giftWrapOption->setCosts(
    36             Money::to_cents( $fee_cost ),
    37             Money::to_cents( $net_cost ),
    38             Money::to_cents( $tax_cost )
     36            Money::to_cents($fee_cost),
     37            Money::to_cents($net_cost),
     38            Money::to_cents($tax_cost)
    3939        );
    4040    }
    4141    $giftWrapAddon->addOption($giftWrapOption);
    42     $value[]=$giftWrapAddon;
     42    $value[] = $giftWrapAddon;
    4343
    4444    return $value;
    4545}
     46
    4647add_filter('simplerwc_quotation_addons', 'simplerwc_compat_quote_tgpc_gift_wrapping_for_woocommerce', 10, 2);
    47 
    4848
    4949function simplerwc_compat_submit_tgpc_gift_wrapping_for_woocommerce($closures, $order_request)
    5050{
    51     if ( ! class_exists( 'Tgpc_Wc_Gift_Wrap' ) ) {
     51    if (!class_exists('Tgpc_Wc_Gift_Wrap')) {
    5252        return $closures;
    5353    }
    5454
    55     if ( get_option( 'tgpc_gift_wrapper_enabled' ) !== 'yes' ){
     55    if (get_option('tgpc_gift_wrapper_enabled') !== 'yes') {
    5656        return $closures;
    5757    }
    5858
    5959    $addons = $order_request->get_order()->get_addons();
    60     if ( empty($addons) ) {
     60    if (empty($addons)) {
    6161        return $closures;
    6262    }
    6363
    6464    $giftWrapAddon = null;
    65     foreach( $addons as $a ){
    66         if( $a['type'] == GiftWrapAddon::type() ){
     65    foreach ($addons as $a) {
     66        if ($a['type'] == GiftWrapAddon::type()) {
    6767            $giftWrapAddon = GiftWrapAddon::from_json($a);
    6868            break;
     
    7070    }
    7171
    72     if( ! $giftWrapAddon ){
     72    if (!$giftWrapAddon) {
    7373        return $closures;
    7474    }
    7575
    7676    $closures[] = function () {
    77         $tgpc_public = new Tgpc_Wc_Gift_Wrap_Public('Tgpc_Wc_Gift_Wrap','v1.0.0');
     77        $tgpc_public = new Tgpc_Wc_Gift_Wrap_Public('Tgpc_Wc_Gift_Wrap', 'v1.0.0');
    7878        $_POST['tgpc_enable_checkout_gift_wrapper'] = true;
    7979        $tgpc_public->tgpc_add_gift_wrapper_fee();
     
    8282    return $closures;
    8383}
     84
    8485add_filter('simplerwc_order_fees', 'simplerwc_compat_submit_tgpc_gift_wrapping_for_woocommerce', 10, 2);
  • simpler-checkout/tags/1.1.7/includes/Compatibility/pickup.php

    r3272319 r3290493  
    1313        function simplerwc_local_pickup_plus_after_set_checkout_data($order, $order_request)
    1414        {
    15             $pickupId = $order_request->get_order()->get_shipping()->get_pickup_location_id();
     15            $pickupId = $order_request->get_order()->get_shipping()?$order_request->get_order()->get_shipping()->get_pickup_location_id():null;
    1616            if (!$pickupId || !class_exists('WC_Local_Pickup_Plus')) {
    1717                return;
     
    2424            }
    2525        }
     26
    2627        add_action('simplerwc_after_set_checkout_data', 'simplerwc_local_pickup_plus_after_set_checkout_data', 10, 2);
    2728    }
    2829}
     30
    2931add_action('init', 'simplerwc_compat_wc_local_pickup_plus');
    3032
    31 
    32 
    33 //WC Pickup Store https://wordpress.org/plugins/wc-pickup-store
     33// WC Pickup Store https://wordpress.org/plugins/wc-pickup-store
    3434function simplerwc_compat_wc_pickup_store_set_store_name($order, $request)
    3535{
     
    4242    }
    4343
    44     $location = $request->get_order()->get_shipping()->get_pickup_location_id();
     44    $location = $request->get_order()->get_shipping()?$request->get_order()->get_shipping()->get_pickup_location_id():null;
    4545    if ($location) {
    4646        $order->add_meta_data('_shipping_pickup_stores', $location);
    4747    }
    4848}
     49
    4950add_action('simplerwc_after_set_checkout_data', 'simplerwc_compat_wc_pickup_store_set_store_name', 10, 2);
  • simpler-checkout/tags/1.1.7/includes/Http/Controllers/ProductController.php

    r3209879 r3290493  
    171171                $obj['attributes_data'] = $this->attributes($product);
    172172            }
     173            $obj = apply_filters('simplerwc_products_to_response', $obj);
    173174            $data[] = $obj;
    174175        }
  • simpler-checkout/tags/1.1.7/includes/Services/CartHelper.php

    r3257191 r3290493  
    33namespace Simpler\Services;
    44
    5 use Exception;
    65use Simpler\Exceptions\{BaseException, InvalidProductException};
    76use Simpler\Models\CartItem;
     7use Exception;
    88
    99trait CartHelper
    1010{
    11 
    1211    private function initialize_cart()
    1312    {
     
    1514        // This prevents updating an existing cart with the one given in the quotation request.
    1615        add_filter('woocommerce_persistent_cart_enabled', '__return_false');
    17         WC()->cart     = new \WC_Cart();
    18         WC()->session  = new \WC_Session_Handler();
     16        WC()->cart = new \WC_Cart();
     17        WC()->session = new \WC_Session_Handler();
    1918        WC()->cart->get_cart_from_session();
    2019    }
     
    2524    private function add_item_to_cart(CartItem $item)
    2625    {
     26        do_action('simplerwc_before_add_to_cart', $item);
    2727        $productAdded = false;
    28         if(!$item->get_bundle_type() && $item->has_bundled()){
    29        
    30             $bundle_type = apply_filters('simplerwc_get_bundle_type_of_the_product', null,\wc_get_product( $item->get_product_id()));
    31            
    32             $item->set_bundle_type($bundle_type);
     28        if (!$item->get_bundle_type() && $item->has_bundled()) {
     29            $bundle_type = apply_filters('simplerwc_get_bundle_type_of_the_product', null, \wc_get_product($item->get_product_id()));
     30
     31            $item->set_bundle_type($bundle_type);
    3332        }
    3433        if ($item->get_bundle_type()) {
     
    5049    }
    5150}
    52 
    53 
  • simpler-checkout/tags/1.1.7/includes/button.php

    r3257191 r3290493  
    257257function simplerwc_get_cart_item_attributes($cart_item, $bundled_cart_items = null, $bundle_type = null)
    258258{
    259     $attrs = simplerwc_get_product_attributes($cart_item['data'], $bundle_type);
     259    $attrs = simplerwc_get_product_attributes($cart_item['data'], $bundle_type, $cart_item);
    260260    if (isset($cart_item['quantity'])) {
    261261        $attrs['quantity'] = $cart_item['quantity'];
    262262    }
    263     if (is_a($cart_item['data'], 'WC_Product_Variation')) {
    264         /*** @var \WC_Product_Variation $product */
    265         $attrs['attributes'] = array_key_exists('variation', $cart_item) ? $cart_item['variation'] : $product->get_variation_attributes();
    266     }
     263
    267264    if (isset($bundled_cart_items) && count($bundled_cart_items) > 0) {
    268265        $attrs['bundled'] = array_values(array_map(function ($el) {
     
    276273 * @param \WC_Product $product The product to extract information from
    277274 */
    278 function simplerwc_get_product_attributes($product,$bundle_type = null)
     275function simplerwc_get_product_attributes($product,$bundle_type = null, $cart_item = null)
    279276{
    280277    $attrs = [
     
    286283        'sold_individually'  => $product->is_sold_individually(),
    287284        'purchasable'        => $product->is_purchasable(),
    288         'attributes'         => apply_filters('simplerwc_button_get_product_attributes', [], $product)
     285        'attributes'         => apply_filters('simplerwc_button_get_product_attributes', [], $product, $cart_item)
    289286    ];
    290287    if (is_a($product, 'WC_Product_Variable')) {
     
    295292    } else if (is_a($product, 'WC_Product_Variation')) {
    296293        /** @var \WC_Product_Variation $product */
    297         $attrs['attributes'] = apply_filters('simplerwc_button_get_product_attributes', $product->get_variation_attributes(), $product);
     294        $attrs['attributes'] = apply_filters('simplerwc_button_get_product_attributes', $product->get_variation_attributes(), $product, $cart_item);
    298295    }
    299296    if($bundle_type){
  • simpler-checkout/tags/1.1.7/includes/compat.php

    r3272319 r3290493  
    44include_once('Compatibility/cod.php');
    55include_once('Compatibility/free-gifts.php');
     6include_once('Compatibility/gift-cards.php');
    67include_once('Compatibility/gift-wrap.php');
    78include_once('Compatibility/pickup.php');
  • simpler-checkout/tags/1.1.7/includes/constants.php

    r3272319 r3290493  
    11<?php
    22
    3 const SIMPLERWC_VERSION = '1.1.6';
     3const SIMPLERWC_VERSION = '1.1.7';
    44
    55function simplerwc_get_sdk_uri()
  • simpler-checkout/tags/1.1.7/includes/takeover.php

    r3239474 r3290493  
    5555        }
    5656
    57         $products = $cart->get_cart();
     57        $products = $cart->get_cart_contents();
    5858        $products_array = [];
    5959
    6060        foreach ($products as $cart_item) {
     61            $product = $cart_item['data'];
    6162            $product_data = [
    62                 'id' => (string)$cart_item['product_id'],
     63                'id' => (string)$product->get_id(),
    6364                'qty' => (string)$cart_item['quantity'],
    6465            ];
    6566            if (!empty($cart_item['variation'])) {
    6667                $attrs = new stdClass();
    67                 foreach ($cart_item['variation'] as $attribute => $value) {
     68                $p_attrs = apply_filters('simplerwc_button_get_product_attributes', $product->get_variation_attributes(), $product, $cart_item);
     69                foreach ($p_attrs as $attribute => $value) {
    6870                    $attrs->{$attribute} = (string)$value;
    6971                }
  • simpler-checkout/tags/1.1.7/simpler.php

    r3272319 r3290493  
    88 * Description: Simpler Checkout lets your customers complete their purchases in seconds, with any payment method they want, in any device or browser and without a password.
    99 * Tags: woocommerce, checkout, payments, conversion rate
    10  * Version: 1.1.6
     10 * Version: 1.1.7
    1111 * Requires at least: 5.1
    12  * Tested up to: 6.3.1
     12 * Tested up to: 6.8.1
    1313 * Requires PHP: 7.0
    1414 * License: GPLv3
  • simpler-checkout/tags/1.1.7/vendor/autoload.php

    r3272319 r3290493  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3::getLoader();
     7return ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b::getLoader();
  • simpler-checkout/tags/1.1.7/vendor/composer/autoload_real.php

    r3272319 r3290493  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3
     5class ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
  • simpler-checkout/tags/1.1.7/vendor/composer/autoload_static.php

    r3272319 r3290493  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitc151c635e566471924c6a51e32d8b1e3
     7class ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    8989    {
    9090        return \Closure::bind(function () use ($loader) {
    91             $loader->prefixLengthsPsr4 = ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::$prefixLengthsPsr4;
    92             $loader->prefixDirsPsr4 = ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::$prefixDirsPsr4;
    93             $loader->classMap = ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::$classMap;
     91            $loader->prefixLengthsPsr4 = ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::$prefixLengthsPsr4;
     92            $loader->prefixDirsPsr4 = ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::$prefixDirsPsr4;
     93            $loader->classMap = ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::$classMap;
    9494
    9595        }, null, ClassLoader::class);
  • simpler-checkout/tags/1.1.7/vendor/composer/installed.php

    r3272319 r3290493  
    11<?php return array(
    22    'root' => array(
    3         'pretty_version' => '1.1.6',
    4         'version' => '1.1.6.0',
     3        'pretty_version' => '1.1.7',
     4        'version' => '1.1.7.0',
    55        'type' => 'wordpress-plugin',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => '6abeec6ddab3c1396ae34fdae5700fc18085a09b',
     8        'reference' => 'd9107f5b5c2f0d7f288673fc5289e91e3f020004',
    99        'name' => 'simpler-checkout/woo',
    1010        'dev' => false,
     
    1212    'versions' => array(
    1313        'simpler-checkout/woo' => array(
    14             'pretty_version' => '1.1.6',
    15             'version' => '1.1.6.0',
     14            'pretty_version' => '1.1.7',
     15            'version' => '1.1.7.0',
    1616            'type' => 'wordpress-plugin',
    1717            'install_path' => __DIR__ . '/../../',
    1818            'aliases' => array(),
    19             'reference' => '6abeec6ddab3c1396ae34fdae5700fc18085a09b',
     19            'reference' => 'd9107f5b5c2f0d7f288673fc5289e91e3f020004',
    2020            'dev_requirement' => false,
    2121        ),
  • simpler-checkout/trunk/README.txt

    r3272319 r3290493  
    55Tested up to: 6.5
    66Requires PHP: 7.0
    7 Stable tag: 1.1.6
     7Stable tag: 1.1.7
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    3535
    3636== Changelog ==
     37
     38== 1.1.7
     39Compat: [pw woocommerce gift cards] (https://wordpress.org/plugins/pw-woocommerce-gift-cards/)
    3740
    3841== 1.1.6
  • simpler-checkout/trunk/includes/Compatibility/bundles.php

    r3272319 r3290493  
    99    return $value;
    1010}
     11
    1112add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_wc_pb_cart_item_is_bundled', 10, 2);
    1213
     
    1819    return $value;
    1920}
     21
    2022add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_wc_pb_cart_item_is_bundle_container', 10, 2);
    2123
    2224function simplerwc_compat_wc_pb_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    2325{
    24     if($bundle_type!='wc_pb') return $value;
    25 
    26     if (function_exists('wc_pb_get_bundled_cart_items') ){
     26    if ($bundle_type != 'wc_pb')
     27        return $value;
     28
     29    if (function_exists('wc_pb_get_bundled_cart_items')) {
    2730        $bundled_items = \wc_pb_get_bundled_cart_items($cart_item);
    2831        foreach ($bundled_items as $idx => $item) {
     
    3437    return $value;
    3538}
     39
    3640add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_wc_pb_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    3741
     
    4347    return $value;
    4448}
     49
    4550add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_wc_pb_product_is_bundle_container', 10, 2);
    4651
    4752function simplerwc_compat_wc_pb_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    4853{
    49     if($bundle_type!='wc_pb') return $value;
     54    if ($bundle_type != 'wc_pb')
     55        return $value;
    5056
    5157    if (is_a($product, 'WC_Product_Bundle') && class_exists('WC_PB_DB')) {
     
    6571    return $value;
    6672}
     73
    6774add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_wc_pb_get_all_products_linked_to_the_bundle_product', 10, 3);
    6875
    6976function simplerwc_compat_wc_pb_add_simpler_bundle_to_cart($value, $simpler_item)
    7077{
    71     if($simpler_item->get_bundle_type()!='wc_pb') return $value;
    72 
    73     if (!class_exists('WC_PB_DB')) return $value;
     78    if ($simpler_item->get_bundle_type() != 'wc_pb')
     79        return $value;
     80
     81    if (!class_exists('WC_PB_DB'))
     82        return $value;
    7483
    7584    // the final bundle configuration to be added to cart
     
    7887    // get bundle configurations
    7988    $bundled = \WC_PB_DB::query_bundled_items(array(
    80         'return'    => 'id=>product_id',
     89        'return' => 'id=>product_id',
    8190        'bundle_id' => array($simpler_item->get_product_id())
    8291    ));
     
    125134    );
    126135}
     136
    127137function simplerwc_compat_wc_pb_construct_variation_configuration($bundle, $product)
    128138{
     
    138148    return $c;
    139149}
     150
    140151add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_wc_pb_add_simpler_bundle_to_cart', 10, 2);
    141152
    142 function simplerwc_compat_wc_pb_get_product_type_of_the_bundle($value,$bundle_type)
    143 {
    144     if($bundle_type=='wc_pb') return 'bundle';
    145     return $value;
    146 }
     153function simplerwc_compat_wc_pb_get_product_type_of_the_bundle($value, $bundle_type)
     154{
     155    if ($bundle_type == 'wc_pb')
     156        return 'bundle';
     157    return $value;
     158}
     159
    147160add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_wc_pb_get_product_type_of_the_bundle', 10, 2);
    148161
    149 function simplerwc_compat_wc_pb_get_bundle_type_of_the_product($value,$product)
    150 {
    151     if($value) return $value;
     162function simplerwc_compat_wc_pb_get_bundle_type_of_the_product($value, $product)
     163{
     164    if ($value)
     165        return $value;
    152166    if (is_a($product, 'WC_Product_Bundle') && class_exists('WC_PB_DB')) {
    153167        return 'wc_pb';
     
    155169    return $value;
    156170}
     171
    157172add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_wc_pb_get_bundle_type_of_the_product', 10, 2);
    158 
    159 
    160173
    161174// WPC Smart Bundles
    162175function simplerwc_compat_woosb_cart_item_is_bundled($value, $cart_item)
    163176{
    164     if (array_key_exists('woosb_parent_id',$cart_item)) {
     177    if (array_key_exists('woosb_parent_id', $cart_item)) {
    165178        return true;
    166179    }
    167180    return $value;
    168181}
     182
    169183add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_woosb_cart_item_is_bundled', 10, 2);
    170184
    171185function simplerwc_compat_woosb_cart_item_is_bundle_container($value, $cart_item)
    172186{
    173     if (isset($cart_item['woosb_ids']) && !empty($cart_item['woosb_ids'])){
     187    if (isset($cart_item['woosb_ids']) && !empty($cart_item['woosb_ids'])) {
    174188        return 'woosb';
    175189    }
    176190    return $value;
    177191}
     192
    178193add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_woosb_cart_item_is_bundle_container', 10, 2);
    179194
    180195function simplerwc_compat_woosb_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    181196{
    182     if($bundle_type!='woosb') return $value;
     197    if ($bundle_type != 'woosb')
     198        return $value;
    183199
    184200    $bundled_items = [];
    185201    $bundle_ids = explode(',', $cart_item['woosb_ids']);
    186    
     202
    187203    foreach ($bundle_ids as $id) {
    188204        foreach ($cart->get_cart_contents() as $item) {
     
    195211    return $bundled_items;
    196212}
     213
    197214add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_woosb_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    198215
    199216function simplerwc_compat_woosb_product_is_bundle_container($value, $product)
    200217{
    201     if (is_a( $product, 'WC_Product_Woosb' )) {
     218    if (is_a($product, 'WC_Product_Woosb')) {
    202219        return 'woosb';
    203220    }
    204221    return $value;
    205222}
     223
    206224add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_woosb_product_is_bundle_container', 10, 2);
    207225
    208226function simplerwc_compat_woosb_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    209227{
    210     if($bundle_type!='woosb') return $value;
    211 
    212     if (is_a( $product, 'WC_Product_Woosb' )) {
     228    if ($bundle_type != 'woosb')
     229        return $value;
     230
     231    if (is_a($product, 'WC_Product_Woosb')) {
    213232        $bundle_items = $product->get_meta('woosb_ids');
    214233        if (is_array($bundle_items)) {
     
    226245    return $value;
    227246}
     247
    228248add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_woosb_get_all_products_linked_to_the_bundle_product', 10, 3);
    229249
    230250function simplerwc_compat_woosb_add_simpler_bundle_to_cart($value, $simpler_item)
    231251{
    232     if($simpler_item->get_bundle_type()!='woosb') return $value;
    233 
    234     if (!class_exists('WPCleverWoosb')) return $value;
     252    if ($simpler_item->get_bundle_type() != 'woosb')
     253        return $value;
     254
     255    if (!class_exists('WPCleverWoosb'))
     256        return $value;
    235257
    236258    $WPCleverWoosb = new \WPCleverWoosb;
    237259    $cart_data = apply_filters('simplerwc_get_cart_item_data', [], $simpler_item);
    238        
    239     $product_id = $simpler_item->get_product_id(); 
    240     $quantity = $simpler_item->get_quantity(); 
    241     $variation_id = NULL; 
    242     $variation = $simpler_item->get_attributes_array(); 
    243 
    244     $cart_item_data = $WPCleverWoosb->add_cart_item_data($cart_data,$product_id);
    245     if(isset($cart_item_data['woosb_ids'])){
     260
     261    $product_id = $simpler_item->get_product_id();
     262    $quantity = $simpler_item->get_quantity();
     263    $variation_id = NULL;
     264    $variation = $simpler_item->get_attributes_array();
     265
     266    $cart_item_data = $WPCleverWoosb->add_cart_item_data($cart_data, $product_id);
     267    if (isset($cart_item_data['woosb_ids'])) {
    246268        $new_woosb_ids = [];
    247         $woosb_ids = explode(',',$cart_item_data['woosb_ids']);
    248         foreach($woosb_ids as $woosb_id){
    249             list($pid,$pkey,$pqty) = explode('/',$woosb_id);
    250             foreach($simpler_item->get_bundled() as $b_item){
    251                 if($pid == $b_item['product_id']){
     269        $woosb_ids = explode(',', $cart_item_data['woosb_ids']);
     270        foreach ($woosb_ids as $woosb_id) {
     271            list($pid, $pkey, $pqty) = explode('/', $woosb_id);
     272            foreach ($simpler_item->get_bundled() as $b_item) {
     273                if ($pid == $b_item['product_id']) {
    252274                    $pqty = $b_item['quantity'];
    253                     $new_woosb_id = implode('/',[$pid,$pkey,$pqty]);
    254                     $new_woosb_ids[]=$new_woosb_id;
     275                    $new_woosb_id = implode('/', [$pid, $pkey, $pqty]);
     276                    $new_woosb_ids[] = $new_woosb_id;
    255277                }
    256278            }
    257279        }
    258         $cart_item_data['woosb_ids'] = implode(',',$new_woosb_ids);
     280        $cart_item_data['woosb_ids'] = implode(',', $new_woosb_ids);
    259281    }
    260282
    261283    $cart_item_key = WC()->cart->add_to_cart(
    262         $product_id, 
    263         $quantity,   
    264         $variation_id, 
    265         $variation, 
    266         $cart_item_data 
     284        $product_id,
     285        $quantity,
     286        $variation_id,
     287        $variation,
     288        $cart_item_data
    267289    );
    268    
    269     $WPCleverWoosb->add_to_cart($cart_item_key, $product_id, $quantity,null,[],$cart_item_data);
     290
     291    $WPCleverWoosb->add_to_cart($cart_item_key, $product_id, $quantity, null, [], $cart_item_data);
    270292    return $cart_item_key;
    271293}
     294
    272295add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_woosb_add_simpler_bundle_to_cart', 10, 2);
    273296
    274297function simplerwc_compat_woosb_before_create_quoted_product($lineItem)
    275298{
    276     if(isset($lineItem['woosb_price'])){
     299    if (isset($lineItem['woosb_price'])) {
    277300        $lineItem['line_total'] = $lineItem['woosb_price'];
    278301        $lineItem['line_subtotal'] = $lineItem['woosb_price'];
    279302    }
    280     if(isset($lineItem['woosb_parent_id'])){
     303    if (isset($lineItem['woosb_parent_id'])) {
    281304        $lineItem['line_total'] = 0;
    282305        $lineItem['line_subtotal'] = 0;
     
    284307    return $lineItem;
    285308}
     309
    286310add_filter('simplerwc_before_create_quoted_product', 'simplerwc_compat_woosb_before_create_quoted_product', 10, 1);
    287311
    288 function simplerwc_compat_woosb_get_product_type_of_the_bundle($value,$bundle_type)
    289 {
    290     if($bundle_type=='woosb') return 'bundle';
    291     return $value;
    292 }
     312function simplerwc_compat_woosb_get_product_type_of_the_bundle($value, $bundle_type)
     313{
     314    if ($bundle_type == 'woosb')
     315        return 'bundle';
     316    return $value;
     317}
     318
    293319add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_woosb_get_product_type_of_the_bundle', 10, 2);
    294320
    295 function simplerwc_compat_woosb_get_bundle_type_of_the_product($value,$product)
    296 {
    297     if($value) return $value;
    298     if (is_a( $product, 'WC_Product_Woosb' )) {
     321function simplerwc_compat_woosb_get_bundle_type_of_the_product($value, $product)
     322{
     323    if ($value)
     324        return $value;
     325    if (is_a($product, 'WC_Product_Woosb')) {
    299326        return 'woosb';
    300327    }
    301328    return $value;
    302329}
     330
    303331add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_woosb_get_bundle_type_of_the_product', 10, 2);
    304 
    305 
    306332
    307333// WPC Frequently Brought Together
    308334function simplerwc_compat_woobt_cart_item_is_bundled($value, $cart_item)
    309335{
    310     if (array_key_exists('woobt_parent_id',$cart_item)) {
     336    if (array_key_exists('woobt_parent_id', $cart_item)) {
    311337        return true;
    312338    }
    313339    return $value;
    314340}
     341
    315342add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_woobt_cart_item_is_bundled', 10, 2);
    316343
    317344function simplerwc_compat_woobt_cart_item_is_bundle_container($value, $cart_item)
    318345{
    319     if (isset($cart_item['woobt_ids']) && !empty($cart_item['woobt_ids'])){
     346    if (isset($cart_item['woobt_ids']) && !empty($cart_item['woobt_ids'])) {
    320347        return 'woobt';
    321348    }
    322349    return $value;
    323350}
     351
    324352add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_woobt_cart_item_is_bundle_container', 10, 2);
    325353
    326354function simplerwc_compat_woobt_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    327355{
    328     if($bundle_type!='woobt') return $value;
     356    if ($bundle_type != 'woobt')
     357        return $value;
    329358
    330359    $bundled_items = [];
    331360    $bundle_ids = explode(',', $cart_item['woobt_ids']);
    332    
     361
    333362    foreach ($bundle_ids as $bundle_line) {
    334         list($id,$code,$qty) = explode('/',$bundle_line);
     363        list($id, $code, $qty) = explode('/', $bundle_line);
    335364        foreach ($cart->get_cart_contents() as $item) {
    336             if ($item['product_id'] == $id && isset($item['woobt_parent_id']) && $item['woobt_parent_id']==$cart_item['product_id']) {
     365            if ($item['product_id'] == $id && isset($item['woobt_parent_id']) && $item['woobt_parent_id'] == $cart_item['product_id']) {
    337366                $bundled_items[] = $item;
    338367                break;
     
    342371    return $bundled_items;
    343372}
     373
    344374add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_woobt_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    345375
     
    348378    $linked_products = get_post_meta($product->get_id(), 'woobt_ids', true);
    349379
    350     if (empty($linked_products)) return $value;
    351    
     380    if (empty($linked_products))
     381        return $value;
     382
    352383    return 'woobt';
    353384}
     385
    354386add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_woobt_product_is_bundle_container', 10, 2);
    355387
    356388function simplerwc_compat_woobt_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    357389{
    358     if($bundle_type!='woobt') return $value;
     390    if ($bundle_type != 'woobt')
     391        return $value;
    359392
    360393    $linked_products = get_post_meta($product->get_id(), 'woobt_ids', true);
    361394
    362     if (empty($linked_products)) return $value;
     395    if (empty($linked_products))
     396        return $value;
    363397
    364398    $linked_products = maybe_unserialize($linked_products);
    365    
     399
    366400    foreach ($linked_products as $key => $item) {
    367401        if (isset($item['id'])) {
    368402            $product = wc_get_product($item['id']);
    369403            if ($product) {
    370                 $value[]=$product;
    371             }
    372         }
    373     }
    374     return $value;
    375 }
     404                $value[] = $product;
     405            }
     406        }
     407    }
     408    return $value;
     409}
     410
    376411add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_woobt_get_all_products_linked_to_the_bundle_product', 10, 3);
    377412
    378413function simplerwc_compat_woobt_add_simpler_bundle_to_cart($value, $simpler_item)
    379414{
    380     if($simpler_item->get_bundle_type()!='woobt') return $value;
     415    if ($simpler_item->get_bundle_type() != 'woobt')
     416        return $value;
    381417
    382418    $main_product_metadata = apply_filters('simplerwc_get_cart_item_data', [], $simpler_item);
    383    
    384     $main_product_id = $simpler_item->get_product_id(); 
     419
     420    $main_product_id = $simpler_item->get_product_id();
    385421    $main_product_cart_key = WC()->cart->add_to_cart(
    386         $main_product_id, 
    387         $simpler_item->get_quantity(),   
    388         null, 
    389         $simpler_item->get_attributes_array(), 
     422        $main_product_id,
     423        $simpler_item->get_quantity(),
     424        null,
     425        $simpler_item->get_attributes_array(),
    390426        $main_product_metadata
    391427    );
    392428    $value = $main_product_cart_key;
    393    
     429
    394430    if (class_exists('WPCleverWoobt')) {
    395431        $WPCleverWoobt = new \WPCleverWoobt;
     
    397433        $main_product_metadata['woobt_ids'] = '';
    398434        $ids = [];
    399         $linked_products = $WPCleverWoobt->get_product_items( $main_product_id );
    400         foreach ($linked_products as $linked_key => $linked_product){
    401             foreach($simpler_item->get_bundled() as $simpler_bundled_item){
    402                 if($simpler_bundled_item['product_id'] == $linked_product['id']){
    403                     $ids[] = $simpler_bundled_item['product_id'].'/'.$linked_key.'/'.$simpler_bundled_item['quantity'];
     435        $linked_products = $WPCleverWoobt->get_product_items($main_product_id);
     436        foreach ($linked_products as $linked_key => $linked_product) {
     437            foreach ($simpler_item->get_bundled() as $simpler_bundled_item) {
     438                if ($simpler_bundled_item['product_id'] == $linked_product['id']) {
     439                    $ids[] = $simpler_bundled_item['product_id'] . '/' . $linked_key . '/' . $simpler_bundled_item['quantity'];
    404440                }
    405441            }
    406442        }
    407         $main_product_metadata['woobt_ids']=implode(',',$ids);
     443        $main_product_metadata['woobt_ids'] = implode(',', $ids);
    408444        $WPCleverWoobt->add_to_cart(
    409             $main_product_cart_key, 
    410             $main_product_id, 
     445            $main_product_cart_key,
     446            $main_product_id,
    411447            $simpler_item->get_quantity(),
    412448            null,
    413             $simpler_item->get_attributes_array(), 
     449            $simpler_item->get_attributes_array(),
    414450            $main_product_metadata
    415451        );
     
    419455    return $value;
    420456}
     457
    421458add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_woobt_add_simpler_bundle_to_cart', 10, 2);
    422459
    423 function simplerwc_compat_woobt_get_product_type_of_the_bundle($value,$bundle_type)
    424 {
    425     return $value;
    426 }
     460function simplerwc_compat_woobt_get_product_type_of_the_bundle($value, $bundle_type)
     461{
     462    return $value;
     463}
     464
    427465add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_woobt_get_product_type_of_the_bundle', 10, 2);
    428466
    429 function simplerwc_compat_woobt_get_bundle_type_of_the_product($value,$product)
    430 {
    431     if($value) return $value;
     467function simplerwc_compat_woobt_get_bundle_type_of_the_product($value, $product)
     468{
     469    if ($value)
     470        return $value;
    432471    $linked_products = get_post_meta($product->get_id(), 'woobt_ids', true);
    433     if (!empty($linked_products)) return 'woobt';
    434     return $value;
    435 }
     472    if (!empty($linked_products))
     473        return 'woobt';
     474    return $value;
     475}
     476
    436477add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_woobt_get_bundle_type_of_the_product', 10, 2);
    437 
    438 
    439478
    440479// WC Linked products
    441480function simplerwc_compat_woocommerce_cart_item_is_bundled($value, $cart_item)
    442481{
    443     if (array_key_exists('bundle_sell_of',$cart_item)) {
     482    if (array_key_exists('bundle_sell_of', $cart_item)) {
    444483        return true;
    445484    }
    446485    return $value;
    447486}
     487
    448488add_filter('simplerwc_cart_item_is_bundled', 'simplerwc_compat_woocommerce_cart_item_is_bundled', 10, 2);
    449489
    450490function simplerwc_compat_woocommerce_cart_item_is_bundle_container($value, $cart_item)
    451491{
    452     if (isset($cart_item['bundle_sells']) && !empty($cart_item['bundle_sells'])){
     492    if (isset($cart_item['bundle_sells']) && !empty($cart_item['bundle_sells'])) {
    453493        return 'woocommerce';
    454494    }
    455495    return $value;
    456496}
     497
    457498add_filter('simplerwc_cart_item_is_bundle_container', 'simplerwc_compat_woocommerce_cart_item_is_bundle_container', 10, 2);
    458499
    459500function simplerwc_compat_woocommerce_get_selected_cart_items_linked_to_the_bundle_cart_item($value, $cart, $cart_item, $bundle_type)
    460501{
    461     if($bundle_type!='woocommerce') return $value;
     502    if ($bundle_type != 'woocommerce')
     503        return $value;
    462504
    463505    $bundled_items = [];
    464     $cross_sell_items = $cart_item["bundle_sells"] ?? [];
     506    $cross_sell_items = $cart_item['bundle_sells'] ?? [];
    465507    foreach ($cross_sell_items as $id) {
    466508        $bundled_items[] = $cart->get_cart_item($id);
     
    468510    return $bundled_items;
    469511}
     512
    470513add_filter('simplerwc_get_selected_cart_items_linked_to_the_bundle_cart_item', 'simplerwc_compat_woocommerce_get_selected_cart_items_linked_to_the_bundle_cart_item', 10, 4);
    471514
     
    474517    $linked_products = get_post_meta($product->get_id(), 'bundle_sells', true);
    475518
    476     if (empty($linked_products)) return $value;
    477    
    478     return $value;
    479 }
     519    if (empty($linked_products))
     520        return $value;
     521
     522    return $value;
     523}
     524
    480525add_filter('simplerwc_product_is_bundle_container', 'simplerwc_compat_woocommerce_product_is_bundle_container', 10, 2);
    481526
    482527function simplerwc_compat_woocommerce_get_all_products_linked_to_the_bundle_product($value, $product, $bundle_type)
    483528{
    484     if($bundle_type!='woocommerce') return $value;
    485 
    486     return $value;
    487 }
     529    if ($bundle_type != 'woocommerce')
     530        return $value;
     531
     532    return $value;
     533}
     534
    488535add_filter('simplerwc_get_all_products_linked_to_the_bundle_product', 'simplerwc_compat_woocommerce_get_all_products_linked_to_the_bundle_product', 10, 3);
    489536
    490537function simplerwc_compat_woocommerce_add_simpler_bundle_to_cart($value, $simpler_item)
    491538{
    492     if($simpler_item->get_bundle_type()!='woocommerce') return $value;
     539    if ($simpler_item->get_bundle_type() != 'woocommerce')
     540        return $value;
    493541
    494542    $main_product_cart_key = \WC()->cart->add_to_cart(
     
    515563    return $main_product_cart_key;
    516564}
     565
    517566add_filter('simplerwc_add_simpler_bundle_to_cart', 'simplerwc_compat_woocommerce_add_simpler_bundle_to_cart', 10, 2);
    518567
    519 function simplerwc_compat_woocommerce_get_product_type_of_the_bundle($value,$bundle_type)
    520 {
    521     return $value;
    522 }
     568function simplerwc_compat_woocommerce_get_product_type_of_the_bundle($value, $bundle_type)
     569{
     570    return $value;
     571}
     572
    523573add_filter('simplerwc_get_product_type_of_the_bundle', 'simplerwc_compat_woocommerce_get_product_type_of_the_bundle', 10, 2);
    524574
    525 function simplerwc_compat_woocommerce_get_bundle_type_of_the_product($value,$product)
    526 {
    527     if($value) return $value;
    528     return 'woocommerce';
    529 }
     575function simplerwc_compat_woocommerce_get_bundle_type_of_the_product($value, $product)
     576{
     577    if ($value)
     578        return $value;
     579    return 'woocommerce';
     580}
     581
    530582add_filter('simplerwc_get_bundle_type_of_the_product', 'simplerwc_compat_woocommerce_get_bundle_type_of_the_product', 11, 2);
  • simpler-checkout/trunk/includes/Compatibility/cod.php

    r3272319 r3290493  
    66use Simpler\Models\Quotation;
    77
    8 
    98/**
    109 * @param  Quotation  $quotation
     
    1312 * @return PaymentMethod[]
    1413 */
    15 function simplerwc_compat_wc_smart_cod_quote(array $paymentMethods, Quotation $quotation) {
    16 
     14function simplerwc_compat_wc_smart_cod_quote(array $paymentMethods, Quotation $quotation)
     15{
    1716    $shippingMethod = $quotation->get_shipping_rate();
    1817
    19     if(!$shippingMethod) {
     18    if (!$shippingMethod) {
    2019        return $paymentMethods;
    2120    }
    2221
    23     if(!defined('DOING_AJAX')) define('DOING_AJAX',true);
     22    if (!defined('DOING_AJAX'))
     23        define('DOING_AJAX', true);
    2424    $availablePaymentMethods = WC()->payment_gateways->get_available_payment_gateways();
    25    
     25
    2626    $codCost = 0;
    27     if (isset($availablePaymentMethods['cod']) ) {
    28         if ($availablePaymentMethods['cod'] instanceof \WC_Smart_COD_Admin ) {
     27    if (isset($availablePaymentMethods['cod'])) {
     28        if ($availablePaymentMethods['cod'] instanceof \WC_Smart_COD_Admin) {
    2929            $smartCod = new \WC_Smart_COD_Public('wc-smart-cod');
    3030            $smartCod->init_wsc_settings();
    31             if(!$smartCod->has_cod_available()){
     31            if (!$smartCod->has_cod_available()) {
    3232                return $paymentMethods;
    3333            }
    34             $codCost = $smartCod->apply_smart_cod_fees(WC()->cart,false);
    35             if (isset($availablePaymentMethods['cod']->settings['extra_fee_tax']) && $availablePaymentMethods['cod']->settings['extra_fee_tax']=='enable') {
    36                 $taxes = \wc_array_merge_recursive_numeric([],\WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false));
     34            $codCost = $smartCod->apply_smart_cod_fees(WC()->cart, false);
     35            if (isset($availablePaymentMethods['cod']->settings['extra_fee_tax']) && $availablePaymentMethods['cod']->settings['extra_fee_tax'] == 'enable') {
     36                $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($codCost, \WC_Tax::get_rates(''), false));
    3737                if (!empty($taxes)) {
    3838                    $codCost += array_sum($taxes);
     
    5858add_filter('simplerwc_quotation_payment_method', 'simplerwc_compat_wc_smart_cod_quote', 10, 2);
    5959
    60 
    6160/**
    6261 * @param  Closure[]     $closures
     
    6867{
    6968    if (
    70         !($paymentMethod = $orderRequest->get_order()->get_payment_method())
    71         || $paymentMethod->getType() != PaymentMethod::COD
    72         || !class_exists('Wc_Smart_Cod_Admin')
     69        !($paymentMethod = $orderRequest->get_order()->get_payment_method()) ||
     70        $paymentMethod->getType() != PaymentMethod::COD ||
     71        !class_exists('Wc_Smart_Cod_Admin')
    7372    ) {
    7473        return $closures;
  • simpler-checkout/trunk/includes/Compatibility/free-gifts.php

    r3272319 r3290493  
    1818    }
    1919}
     20
    2021add_action('simplerwc_after_add_to_cart', 'simplerwc_fgf_after_add_to_cart');
    21 
    22 
    2322
    2423// iThemeland Free Gifts : https://ithemelandco.com/plugins/free-gifts-for-woocommerce/
     
    4443add_filter('simplerwc_button_should_ignore_cart_item', 'simplerwc_compat_ithemeland_free_gifts_ignore', 10, 2);
    4544
    46 
    47 
    4845// BOGO https://woocommerce.com/products/buy-one-get-one-free/
    4946function simplerwc_compat_bogof_free_gifts_ignore($value, $cart_item)
     
    5451    return $value;
    5552}
     53
    5654add_filter('simplerwc_button_should_ignore_cart_item', 'simplerwc_compat_bogof_free_gifts_ignore', 10, 2);
    57 
    58 
    5955
    6056// Asana [WooCommerce Dynamic Pricing and Discounts] https://www.asanaplugins.com/product/woocommerce-dynamic-pricing-and-discounts-plugin/
     
    6662    return $value;
    6763}
     64
    6865add_filter('simplerwc_button_should_ignore_cart_item', 'simplerwc_compat_asana_wcdpd_free_gifts_ignore', 10, 2);
    69 
    70 
    7166
    7267// Pricepep [WooCommerce Dynamic Pricing, Discounts & Fees] https://codecanyon.net/item/woocommerce-dynamic-pricing-discounts/7119279
     
    7570    add_filter('rp_wcdpd_request_is_product_feed', '__return_true', 10, 0);
    7671}
     72
    7773add_action('simplerwc_product_controller_request_before', 'simplerwc_rp_wcdpd_set_is_product_feed', 1, 0);
  • simpler-checkout/trunk/includes/Compatibility/gift-wrap.php

    r3272319 r3290493  
    11<?php
    22
    3 use Simpler\Models\Money;
    43use Simpler\Models\GiftWrapAddon;
    54use Simpler\Models\GiftWrapOption;
     5use Simpler\Models\Money;
    66
    77// Gift Wrapping for WooCommerce https://wordpress.com/plugins/gift-wrapping-for-woocommerce
    88function simplerwc_compat_quote_tgpc_gift_wrapping_for_woocommerce($value, $quotation)
    99{
    10     if ( ! class_exists( 'Tgpc_Wc_Gift_Wrap' ) ) {
     10    if (!class_exists('Tgpc_Wc_Gift_Wrap')) {
    1111        return $value;
    1212    }
    1313
    14     if ( get_option( 'tgpc_gift_wrapper_enabled' ) !== 'yes' ){
     14    if (get_option('tgpc_gift_wrapper_enabled') !== 'yes') {
    1515        return $value;
    1616    }
    1717    $giftWrapAddon = new GiftWrapAddon();
    18     $giftWrapOption = new GiftWrapOption("1");
     18    $giftWrapOption = new GiftWrapOption('1');
    1919
    20     $fee_cost   = (float) apply_filters( 'tgpc_wc_gift_wrapper_cost', get_option( 'tgpc_gift_wrapper_cost', 0 ) );
     20    $fee_cost = (float) apply_filters('tgpc_wc_gift_wrapper_cost', get_option('tgpc_gift_wrapper_cost', 0));
    2121    $tax_cost = 0;
    2222    $net_cost = $fee_cost;
    23    
    24     $is_taxable = get_option( 'tgpc_gift_wrapper_cost_tax_status' ) === 'yes';
    25     $tax_class  = get_option( 'tgpc_gift_wrapper_tax_class', '' );
     23
     24    $is_taxable = get_option('tgpc_gift_wrapper_cost_tax_status') === 'yes';
     25    $tax_class = get_option('tgpc_gift_wrapper_tax_class', '');
    2626    if ($is_taxable) {
    27         $taxes = \wc_array_merge_recursive_numeric([],\WC_Tax::calc_tax($fee_cost, $tax_class, false));
     27        $taxes = \wc_array_merge_recursive_numeric([], \WC_Tax::calc_tax($fee_cost, $tax_class, false));
    2828        if (!empty($taxes)) {
    2929            $tax_cost = array_sum($taxes);
     
    3232    }
    3333
    34     if ( $fee_cost ) {
     34    if ($fee_cost) {
    3535        $giftWrapOption->setCosts(
    36             Money::to_cents( $fee_cost ),
    37             Money::to_cents( $net_cost ),
    38             Money::to_cents( $tax_cost )
     36            Money::to_cents($fee_cost),
     37            Money::to_cents($net_cost),
     38            Money::to_cents($tax_cost)
    3939        );
    4040    }
    4141    $giftWrapAddon->addOption($giftWrapOption);
    42     $value[]=$giftWrapAddon;
     42    $value[] = $giftWrapAddon;
    4343
    4444    return $value;
    4545}
     46
    4647add_filter('simplerwc_quotation_addons', 'simplerwc_compat_quote_tgpc_gift_wrapping_for_woocommerce', 10, 2);
    47 
    4848
    4949function simplerwc_compat_submit_tgpc_gift_wrapping_for_woocommerce($closures, $order_request)
    5050{
    51     if ( ! class_exists( 'Tgpc_Wc_Gift_Wrap' ) ) {
     51    if (!class_exists('Tgpc_Wc_Gift_Wrap')) {
    5252        return $closures;
    5353    }
    5454
    55     if ( get_option( 'tgpc_gift_wrapper_enabled' ) !== 'yes' ){
     55    if (get_option('tgpc_gift_wrapper_enabled') !== 'yes') {
    5656        return $closures;
    5757    }
    5858
    5959    $addons = $order_request->get_order()->get_addons();
    60     if ( empty($addons) ) {
     60    if (empty($addons)) {
    6161        return $closures;
    6262    }
    6363
    6464    $giftWrapAddon = null;
    65     foreach( $addons as $a ){
    66         if( $a['type'] == GiftWrapAddon::type() ){
     65    foreach ($addons as $a) {
     66        if ($a['type'] == GiftWrapAddon::type()) {
    6767            $giftWrapAddon = GiftWrapAddon::from_json($a);
    6868            break;
     
    7070    }
    7171
    72     if( ! $giftWrapAddon ){
     72    if (!$giftWrapAddon) {
    7373        return $closures;
    7474    }
    7575
    7676    $closures[] = function () {
    77         $tgpc_public = new Tgpc_Wc_Gift_Wrap_Public('Tgpc_Wc_Gift_Wrap','v1.0.0');
     77        $tgpc_public = new Tgpc_Wc_Gift_Wrap_Public('Tgpc_Wc_Gift_Wrap', 'v1.0.0');
    7878        $_POST['tgpc_enable_checkout_gift_wrapper'] = true;
    7979        $tgpc_public->tgpc_add_gift_wrapper_fee();
     
    8282    return $closures;
    8383}
     84
    8485add_filter('simplerwc_order_fees', 'simplerwc_compat_submit_tgpc_gift_wrapping_for_woocommerce', 10, 2);
  • simpler-checkout/trunk/includes/Compatibility/pickup.php

    r3272319 r3290493  
    1313        function simplerwc_local_pickup_plus_after_set_checkout_data($order, $order_request)
    1414        {
    15             $pickupId = $order_request->get_order()->get_shipping()->get_pickup_location_id();
     15            $pickupId = $order_request->get_order()->get_shipping()?$order_request->get_order()->get_shipping()->get_pickup_location_id():null;
    1616            if (!$pickupId || !class_exists('WC_Local_Pickup_Plus')) {
    1717                return;
     
    2424            }
    2525        }
     26
    2627        add_action('simplerwc_after_set_checkout_data', 'simplerwc_local_pickup_plus_after_set_checkout_data', 10, 2);
    2728    }
    2829}
     30
    2931add_action('init', 'simplerwc_compat_wc_local_pickup_plus');
    3032
    31 
    32 
    33 //WC Pickup Store https://wordpress.org/plugins/wc-pickup-store
     33// WC Pickup Store https://wordpress.org/plugins/wc-pickup-store
    3434function simplerwc_compat_wc_pickup_store_set_store_name($order, $request)
    3535{
     
    4242    }
    4343
    44     $location = $request->get_order()->get_shipping()->get_pickup_location_id();
     44    $location = $request->get_order()->get_shipping()?$request->get_order()->get_shipping()->get_pickup_location_id():null;
    4545    if ($location) {
    4646        $order->add_meta_data('_shipping_pickup_stores', $location);
    4747    }
    4848}
     49
    4950add_action('simplerwc_after_set_checkout_data', 'simplerwc_compat_wc_pickup_store_set_store_name', 10, 2);
  • simpler-checkout/trunk/includes/Http/Controllers/ProductController.php

    r3209879 r3290493  
    171171                $obj['attributes_data'] = $this->attributes($product);
    172172            }
     173            $obj = apply_filters('simplerwc_products_to_response', $obj);
    173174            $data[] = $obj;
    174175        }
  • simpler-checkout/trunk/includes/Services/CartHelper.php

    r3257191 r3290493  
    33namespace Simpler\Services;
    44
    5 use Exception;
    65use Simpler\Exceptions\{BaseException, InvalidProductException};
    76use Simpler\Models\CartItem;
     7use Exception;
    88
    99trait CartHelper
    1010{
    11 
    1211    private function initialize_cart()
    1312    {
     
    1514        // This prevents updating an existing cart with the one given in the quotation request.
    1615        add_filter('woocommerce_persistent_cart_enabled', '__return_false');
    17         WC()->cart     = new \WC_Cart();
    18         WC()->session  = new \WC_Session_Handler();
     16        WC()->cart = new \WC_Cart();
     17        WC()->session = new \WC_Session_Handler();
    1918        WC()->cart->get_cart_from_session();
    2019    }
     
    2524    private function add_item_to_cart(CartItem $item)
    2625    {
     26        do_action('simplerwc_before_add_to_cart', $item);
    2727        $productAdded = false;
    28         if(!$item->get_bundle_type() && $item->has_bundled()){
    29        
    30             $bundle_type = apply_filters('simplerwc_get_bundle_type_of_the_product', null,\wc_get_product( $item->get_product_id()));
    31            
    32             $item->set_bundle_type($bundle_type);
     28        if (!$item->get_bundle_type() && $item->has_bundled()) {
     29            $bundle_type = apply_filters('simplerwc_get_bundle_type_of_the_product', null, \wc_get_product($item->get_product_id()));
     30
     31            $item->set_bundle_type($bundle_type);
    3332        }
    3433        if ($item->get_bundle_type()) {
     
    5049    }
    5150}
    52 
    53 
  • simpler-checkout/trunk/includes/button.php

    r3257191 r3290493  
    257257function simplerwc_get_cart_item_attributes($cart_item, $bundled_cart_items = null, $bundle_type = null)
    258258{
    259     $attrs = simplerwc_get_product_attributes($cart_item['data'], $bundle_type);
     259    $attrs = simplerwc_get_product_attributes($cart_item['data'], $bundle_type, $cart_item);
    260260    if (isset($cart_item['quantity'])) {
    261261        $attrs['quantity'] = $cart_item['quantity'];
    262262    }
    263     if (is_a($cart_item['data'], 'WC_Product_Variation')) {
    264         /*** @var \WC_Product_Variation $product */
    265         $attrs['attributes'] = array_key_exists('variation', $cart_item) ? $cart_item['variation'] : $product->get_variation_attributes();
    266     }
     263
    267264    if (isset($bundled_cart_items) && count($bundled_cart_items) > 0) {
    268265        $attrs['bundled'] = array_values(array_map(function ($el) {
     
    276273 * @param \WC_Product $product The product to extract information from
    277274 */
    278 function simplerwc_get_product_attributes($product,$bundle_type = null)
     275function simplerwc_get_product_attributes($product,$bundle_type = null, $cart_item = null)
    279276{
    280277    $attrs = [
     
    286283        'sold_individually'  => $product->is_sold_individually(),
    287284        'purchasable'        => $product->is_purchasable(),
    288         'attributes'         => apply_filters('simplerwc_button_get_product_attributes', [], $product)
     285        'attributes'         => apply_filters('simplerwc_button_get_product_attributes', [], $product, $cart_item)
    289286    ];
    290287    if (is_a($product, 'WC_Product_Variable')) {
     
    295292    } else if (is_a($product, 'WC_Product_Variation')) {
    296293        /** @var \WC_Product_Variation $product */
    297         $attrs['attributes'] = apply_filters('simplerwc_button_get_product_attributes', $product->get_variation_attributes(), $product);
     294        $attrs['attributes'] = apply_filters('simplerwc_button_get_product_attributes', $product->get_variation_attributes(), $product, $cart_item);
    298295    }
    299296    if($bundle_type){
  • simpler-checkout/trunk/includes/compat.php

    r3272319 r3290493  
    44include_once('Compatibility/cod.php');
    55include_once('Compatibility/free-gifts.php');
     6include_once('Compatibility/gift-cards.php');
    67include_once('Compatibility/gift-wrap.php');
    78include_once('Compatibility/pickup.php');
  • simpler-checkout/trunk/includes/constants.php

    r3272319 r3290493  
    11<?php
    22
    3 const SIMPLERWC_VERSION = '1.1.6';
     3const SIMPLERWC_VERSION = '1.1.7';
    44
    55function simplerwc_get_sdk_uri()
  • simpler-checkout/trunk/includes/takeover.php

    r3239474 r3290493  
    5555        }
    5656
    57         $products = $cart->get_cart();
     57        $products = $cart->get_cart_contents();
    5858        $products_array = [];
    5959
    6060        foreach ($products as $cart_item) {
     61            $product = $cart_item['data'];
    6162            $product_data = [
    62                 'id' => (string)$cart_item['product_id'],
     63                'id' => (string)$product->get_id(),
    6364                'qty' => (string)$cart_item['quantity'],
    6465            ];
    6566            if (!empty($cart_item['variation'])) {
    6667                $attrs = new stdClass();
    67                 foreach ($cart_item['variation'] as $attribute => $value) {
     68                $p_attrs = apply_filters('simplerwc_button_get_product_attributes', $product->get_variation_attributes(), $product, $cart_item);
     69                foreach ($p_attrs as $attribute => $value) {
    6870                    $attrs->{$attribute} = (string)$value;
    6971                }
  • simpler-checkout/trunk/simpler.php

    r3272319 r3290493  
    88 * Description: Simpler Checkout lets your customers complete their purchases in seconds, with any payment method they want, in any device or browser and without a password.
    99 * Tags: woocommerce, checkout, payments, conversion rate
    10  * Version: 1.1.6
     10 * Version: 1.1.7
    1111 * Requires at least: 5.1
    12  * Tested up to: 6.3.1
     12 * Tested up to: 6.8.1
    1313 * Requires PHP: 7.0
    1414 * License: GPLv3
  • simpler-checkout/trunk/vendor/autoload.php

    r3272319 r3290493  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3::getLoader();
     7return ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b::getLoader();
  • simpler-checkout/trunk/vendor/composer/autoload_real.php

    r3272319 r3290493  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3
     5class ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInitc151c635e566471924c6a51e32d8b1e3', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitefc042c3b3729108c3bc76726cf4af6b', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
  • simpler-checkout/trunk/vendor/composer/autoload_static.php

    r3272319 r3290493  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitc151c635e566471924c6a51e32d8b1e3
     7class ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    8989    {
    9090        return \Closure::bind(function () use ($loader) {
    91             $loader->prefixLengthsPsr4 = ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::$prefixLengthsPsr4;
    92             $loader->prefixDirsPsr4 = ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::$prefixDirsPsr4;
    93             $loader->classMap = ComposerStaticInitc151c635e566471924c6a51e32d8b1e3::$classMap;
     91            $loader->prefixLengthsPsr4 = ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::$prefixLengthsPsr4;
     92            $loader->prefixDirsPsr4 = ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::$prefixDirsPsr4;
     93            $loader->classMap = ComposerStaticInitefc042c3b3729108c3bc76726cf4af6b::$classMap;
    9494
    9595        }, null, ClassLoader::class);
  • simpler-checkout/trunk/vendor/composer/installed.php

    r3272319 r3290493  
    11<?php return array(
    22    'root' => array(
    3         'pretty_version' => '1.1.6',
    4         'version' => '1.1.6.0',
     3        'pretty_version' => '1.1.7',
     4        'version' => '1.1.7.0',
    55        'type' => 'wordpress-plugin',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => '6abeec6ddab3c1396ae34fdae5700fc18085a09b',
     8        'reference' => 'd9107f5b5c2f0d7f288673fc5289e91e3f020004',
    99        'name' => 'simpler-checkout/woo',
    1010        'dev' => false,
     
    1212    'versions' => array(
    1313        'simpler-checkout/woo' => array(
    14             'pretty_version' => '1.1.6',
    15             'version' => '1.1.6.0',
     14            'pretty_version' => '1.1.7',
     15            'version' => '1.1.7.0',
    1616            'type' => 'wordpress-plugin',
    1717            'install_path' => __DIR__ . '/../../',
    1818            'aliases' => array(),
    19             'reference' => '6abeec6ddab3c1396ae34fdae5700fc18085a09b',
     19            'reference' => 'd9107f5b5c2f0d7f288673fc5289e91e3f020004',
    2020            'dev_requirement' => false,
    2121        ),
Note: See TracChangeset for help on using the changeset viewer.