Plugin Directory

Changeset 2932041


Ignore:
Timestamp:
06/29/2023 02:40:45 AM (3 years ago)
Author:
upsellpopup
Message:

Tested with Latest wp version

Location:
very-simple-woocommerce-upsell-popup/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • very-simple-woocommerce-upsell-popup/trunk/README.txt

    r2866829 r2932041  
    11=== Woocommerce Upsell / cross sell Popup plugin===
     2
     3
    24Contributors: upsellpopup
     5
     6
    37Donate link: https://woocommerce.upsellpopup.com/
     8
     9
    410Tags: ross sell, upsell, popup, up sell, related products, add to cart popup, added to cart popup, modal, add to cart, cross-sell, cross sell popup
     11
     12
    513Requires at least: 5.0.0
     14
     15
    616Tested up to: 6.1.1
    7 Stable tag: 1.8.7
     17
     18
     19Stable tag: 1.8.9
     20
     21
    822License: GPLv3
     23
     24
    925License URI: https://www.gnu.org/licenses/gpl-3.0.html
    1026
     27
     28
     29
     30
    1131Two in One upsell and cross sell  popup plugin for Woocommerce. Show non-intrusive, responsive popup to your visitors when they click add to cart button. This plugin may be useful for store owners who want a simple and lightweight plugin to recommend product B when user buys product A.
    1232
     33
     34
     35
     36
    1337== Description ==
    1438
     39
     40
     41
     42
    1543[PRO Live Demo](https://demo.upsellpopup.com/)
    1644
     45
     46
     47
     48
    1749An upsell & cross sell popup plugin for Woocommerce. Show non-intrusive, responsive popup to your visitors when they click the add to cart button on the products you specify.
    1850
     51
     52
     53
     54
    1955This plugin may be useful for store owners who want a simple and lightweight plugin to recommend product B when user buys product A. The cross will help sell different product categories and the upsell will improve your AOV cart basket size
     56
     57
    2058One click add to cart with option to add quanitites and several features. Plugin is trusted by more than 40,000 customers so far, highly rated in wordpress.
    2159
     60
     61
     62
     63
    2264This plugin is an extension of the [Woocommerce](https://wordpress.org/plugins/woocommerce/) plugin. You must have Woocommerce active alongside this plugin for it to work properly.
    2365
     66
     67
     68
     69
    2470- Tested with Woocommerce version 6.0.0 up to the latest version 7.2.2.
     71
     72
    2573- This plugin is compatible with PHP 7!
    2674
     75
     76
     77
     78
    2779## What Does It Do
    2880
     81
     82
     83
     84
    2985* When a user clicks on the 'add to cart' button on a product you specify, the product will be added to cart and a yes/no popup will be shown asking if the user is also interested in a complementary product (configurable).
    3086
     87
     88
     89
     90
    3191* For complementary product that the product type is **SIMPLE**: If the user clicks yes, the complementary product will also be added to cart.
    3292
     93
     94
     95
     96
    3397* For complementary product that the product type is **VARIABLE**: If the user clicks yes, you can choose whether to redirect your user to the complementary product's product page, OR to let your user choose a variant on the popup and add that variant to cart without navigating away from popup.
    3498
     99
     100
     101
     102
    35103* After the product you upsell & cross sell is added to user's cart, you can choose whether to redirect user to cart page, checkout page, or make them stay on the same page.
    36104
     105
     106
     107
     108
    37109* If the user clicks no, you can also choose to redirect the user to cart page, checkout page, or stay on the same page.
    38110
     111
     112
     113
     114
    39115* Popup will fire when user adds a product to cart from shop page, product category page, or single product page.
    40116
     117
     118
     119
     120
    41121* **(NEW!)** Now you can easily turn AJAX on and off for add to cart button on single product pages!
    42122
     123
     124
     125
     126
    43127Please refer to screenshots for pre-made templates included in the plugin.
    44128
     129
     130
     131
     132
    45133### Woocommerce Settings
    46134
     135
     136
     137
     138
    47139For the plugin to work as intended, set the Woocommerce setting as follows:
    48140
     141
     142
     143
     144
    49145Go to *Woocommerce > Settings > Products > General > Shop pages*.
    50146
     147
     148
     149
     150
    51151And then for ***'Add to cart behaviour'***, uncheck *'Redirect to the cart page after successful addition'*.
    52152
     153
     154
     155
     156
    53157AJAX can be enabled or disabled for add to cart buttons on archives, popups will fire regardless.
    54158
     159
     160
     161
     162
    55163### Woocommerce Upsell Popup PRO
    56164
     165
     166
     167
     168
    57169Get the [PRO version](https://woocommerce.upsellpopup.com/woocommerce-upsell-popup-pro-plugin/) to have more control of your popups!
    58170
     171
     172
     173
     174
    59175[ [LIVE DEMO!](https://demo.upsellpopup.com/) ]
    60176
     177
     178
     179
     180
    61181**What you can do with our PRO version:**
    62182
     183
     184
     185
     186
    63187- Customize and change the text on your popups!
     188
     189
    64190- Change the text on the popup buttons!
     191
     192
    65193- Customizable popup templates!
     194
     195
    66196- Create your own popup template, and create as many popup templates as you want!
     197
     198
    67199- Upsell & cross sell multiple products per popup.
     200
     201
    68202- Show upsell and cross-sell product prices on your popup.
     203
     204
    69205- Your users will be able to add multiple products to cart from your popup with a click of a button.
     206
     207
    70208- You can create "Frequently bought together with..." popup and show as many products on the popup as you like.
     209
     210
    71211- An option to show "Complete the look" or "Shop the look" concept to encourage your users to buy more items.
    72212
     213
     214
     215
     216
    73217Read plugin documentation [here](https://woocommerce.upsellpopup.com/documentations/).
    74218
     219
     220
     221
     222
    75223### Translation Ready
    76224
     225
     226
     227
     228
    77229The plugin is ready to be translated to your local language, .pot file is included in `/languages` folder.
    78230
     231
     232
     233
     234
    79235### Support
    80236
     237
     238
     239
     240
    81241Please use WordPress.org forum to ask for support, to submit bug reports, to ask questions about the free plugin, or to suggest a new feature.
    82242
     243
     244
     245
     246
    83247Only use the [contact form](https://woocommerce.upsellpopup.com/contact/) on our website if you're inquiring about the PRO version.
    84248
     249
     250
     251
     252
    85253== Installation ==
    86254
     255
     256
     257
     258
    872591. Upload plugin folder to `/wp-content/plugins/` directory, or install the plugin from your WordPress dashboard `Plugins>Add New`.
     260
     261
    882622. Activate the plugin.
     263
     264
    892653. Go to Woocommerce product edit page and start configuring your upsell or cross sell popup.
    90266
     267
     268
     269
     270
    91271== Frequently Asked Questions ==
    92272
     273
     274
     275
     276
    93277= Something is not working! Is there a quick fix? =
    94278
     279
     280
     281
     282
    95283Here's what you could try:
    96284
     285
     286
     287
     288
    97289Go to *Woocommerce > Upsell Popup > General*.
    98290
     291
     292
     293
     294
    99295Here you will see an option to turn off AJAX. Tick the box that says ***'Turn off AJAX on single product pages'***.
    100296
     297
     298
     299
     300
    101301This didn't fix your issue? Here are other things you could try to fix your issue: [Quick Fix](https://woocommerce.upsellpopup.com/docs/woocommerce-upsell-popup-pro-docs/quick-fix-to-most-issues/).
    102302
     303
     304
     305
     306
    103307= How can I customize the popups to have the look and style that I want? =
    104308
     309
     310
     311
     312
    105313If you know CSS, choose ***Template 4 - No CSS*** for your popup and then you can drop your CSS codes in your child theme's stylesheet to style the popup as you like.
    106314
     315
     316
     317
     318
    107319= How can I customize the text on the popups? =
    108320
     321
     322
     323
     324
    109325There are 2 ways to do so.
     326
     327
    1103281. You can use localization (translation) or `gettext` hook to change the text.
     329
     330
    1113312. Or you can get our [PRO version](https://woocommerce.upsellpopup.com/woocommerce-upsell-popup-pro-plugin/) to customize the text on your popups and better - make your own templates!
    112332
     333
     334
     335
     336
    113337= How can I change the Yes/No text on the popup buttons? =
    114338
     339
     340
     341
     342
    115343Same as above. There are 2 ways to do so.
     344
     345
    1163461. You can use localization (translation) or `gettext` hook to change the text.
     347
     348
    1173492. Or you can get our [PRO version](https://woocommerce.upsellpopup.com/woocommerce-upsell-popup-pro-plugin/) in which you will have the option to change the Yes/No text on your popup buttons easily.
    118350
     351
     352
     353
     354
    119355= Can I upsell /cross sell more than one product on my popup? =
    120356
     357
     358
     359
     360
    121361You can do so with our [PRO version](https://woocommerce.upsellpopup.com/woocommerce-upsell-popup-pro-plugin/).
    122362
     363
     364
     365
     366
    123367= Does this plugin support Woocommerce native upsell and cross sell products? =
    124368
     369
     370
     371
     372
    125373Our [PRO version](https://woocommerce.upsellpopup.com/woocommerce-upsell-popup-pro-plugin/) supports Woocommerce native upsell and cross sell products (Woocommerce Linked Products). See this [documentation page](https://woocommerce.upsellpopup.com/docs/woocommerce-upsell-popup-pro-docs/setting-up-upsell-products/).
    126374
     375
     376
     377
     378
    127379= Can I translate this plugin to my language? =
    128380
     381
     382
     383
     384
    129385Yes, this plugin is translation ready, `.pot` file is included in the `/languages` folder.
    130386
     387
     388
     389
     390
    131391== Screenshots ==
    132392
     393
     394
     395
     396
    1333971. Default popup template.
     398
     399
    1344002. Popup template for VARIABLE upsell product.
     401
     402
    1354033. Popup template (Basic).
     404
     405
    1364064. Popup template (Colorful).
     407
     408
    1374095. Popup template (Dark on Light).
     410
     411
    1384126. Upsell popup options on Woocommerce product edit screen.
     413
     414
    1394157. Main setting page.
    140416
     417== Changelog =
     418
     419== 1.8.9 =
     420
     421* Compatibility check with latest wordpress version 6.2.2.
     422
     423== Changelog === 1.8.8 =
     424
     425* Compatibility check with latest wordpress version.
     426
     427
     428
    141429== Changelog === 1.8.7 =
     430
     431
    142432* Compatibility check with latest php version 8.0.28.
    143433
     434
     435
     436
     437
    144438== Changelog === 1.8.6 =
     439
     440
    145441* Color picker issue fixed
    146442
     443
     444
     445
     446
    147447== Changelog === 1.8.5 =
     448
     449
    148450* Deployment issue fixed
    149451
     452
     453
     454
     455
    150456== Changelog === 1.8.4 =
     457
     458
    151459* Additional comments added
    152460
     461
     462
     463
     464
    153465== Changelog === 1.8.3 =
     466
     467
    154468* Compatibility check with latest wordpress version.
    155469
     470
     471
     472
     473
    156474== Changelog === 1.8.2 =
     475
     476
    157477* Compatibility check with pro version.
    158478
     479
     480
     481
     482
    159483== Changelog === 1.8.1 =
     484
     485
    160486* Coupon code and button color change options
    161487
     488
     489
     490
     491
    162492== Changelog === 1.8.0 =
     493
     494
    163495* Reference screenshot added
    164496
     497
     498
     499
     500
    165501== Changelog === 1.7.9 =
     502
     503
    166504* Option to display discount coupon code
    167505
     506
     507
     508
     509
    168510== Changelog === 1.7.8 =
     511
     512
    169513* Compatibility test and fix with wordpress version 6.0.
    170514
     515
     516
     517
     518
    171519= 1.7.7 =
     520
     521
    172522* Quantity options and cart price auto update added.
    173523
     524
     525
     526
     527
    174528= 1.7.6 =
     529
     530
    175531* Multiple quantity options for upsell product global setting for upsell products.
    176532
     533
     534
     535
     536
    177537= 1.7.4 =
     538
     539
    178540* Woocommerce compatibility.
    179541
     542
     543
     544
     545
    180546= 1.7.3 =
     547
     548
    181549* Fixed headers already sent warning when ajax is disabled for add to cart buttons.
    182550
     551
     552
     553
     554
    183555= 1.7.2 =
     556
     557
    184558* Variable Upsell popup template became the new default popup template. The old Variable Upsell template stays unchanged.
     559
     560
    185561* Updated language file.
    186562
     563
     564
     565
     566
    187567= 1.7.1 =
     568
     569
    188570* Fixed bug found in previous two releases.
     571
     572
    189573* Fixed bug for action removal at init hook, added conditional statements accordingly.
    190574
     575
     576
     577
     578
    191579= 1.7.0 =
     580
     581
    192582* Restored Quadlayers ajax add to cart script as default AJAX script for single product pages.
     583
     584
    193585* Added ability for users to switch between Quadlayers ajax script and native Woocommerce handler.
     586
     587
    194588* Updated language file.
    195589
     590
     591
     592
     593
    196594= 1.6.0 =
     595
     596
    197597* Replaced Quadlayers ajax add to cart script, now using Woocommerce native handler, fixing certain product types not correctly adding to cart issue.
     598
     599
    198600* Fixed redirection behavior bug for the NO buttons when AJAX is turned off on single product pages.
     601
     602
    199603* Disabled out of stock variant from being selected on variable upsell template.
     604
     605
    200606* Added validation check for variable upsell template, warning shown if no option is selected.
     607
     608
    201609* Updated language file.
    202610
     611
     612
     613
     614
    203615= 1.5.0 =
     616
     617
    204618* Added an option to let user choose whether to use AJAX or no AJAX for add to cart button on single product pages. AJAX is still enabled by default.
     619
     620
    205621* Fixed certain product types not adding to cart (only without AJAX add to cart button).
     622
     623
    206624* Added support for LearnDash LMS (Woocommerce integration) course product type.
     625
     626
    207627* Updated language file.
    208628
     629
     630
     631
     632
    209633= 1.4.1 =
     634
     635
    210636* Added a new template for variable upsell product to enable user to choose variant on popup without navigating away.
     637
     638
    211639* Fixed loading spinner overlay not covering whole popup (css fix).
     640
     641
    212642* All links changed to the new plugin website.
    213643
     644
     645
     646
     647
    214648= 1.4.0 =
     649
     650
    215651* New plugin structure, revised how popup is called on single product page.
     652
     653
    216654* Added AJAX to add to cart button on single product page by default for faster loading of popup.
     655
     656
    217657* Fixed headers already sent error on single product page.
     658
     659
    218660* Added a new template (Template 2) to PRO template selection.
     661
     662
    219663* Updated language file.
    220664
     665
     666
     667
     668
    221669= 1.3.1 =
     670
     671
    222672* Removed font family in default popup template so that default font in user's theme will be used.
     673
     674
    223675* Additional checks added for admin_init hook when checking for pro compatibility.
     676
     677
    224678* Added a new link on documentation tab settings.
    225679
     680
     681
     682
     683
    226684= 1.3.0 =
     685
     686
    227687* Global and product category setting page added to make it easier for store owners to manage hundreds or thousands of products, either by category or by store-wide.
     688
     689
    228690* Implemented tabs for cleaner settings UI, added new support and documentation page.
     691
     692
    229693* Moved functions related to metabox and global setting page to separate files for better maintenance.
     694
     695
    230696* Changed free/pro structure, only pro version 1.1.2 and above are compatible with this version.
     697
     698
    231699* Updated language file.
    232700
     701
     702
     703
     704
    233705= 1.2.3 =
     706
     707
    234708* Improved security and sanitization for metabox user input.
     709
     710
    235711* Maintained compatibilty with pro version.
    236712
     713
     714
     715
     716
    237717= 1.2.2 =
     718
     719
    238720* Removed out of stock upsell products from being displayed on popups.
     721
     722
    239723* Improved the handling of variations at popup level.
     724
     725
    240726* Now only published product and active product variations get shown on popups.
    241727
     728
     729
     730
     731
    242732= 1.2.1 =
     733
     734
    243735* Added url validation and sanitization before redirection.
     736
     737
    244738* Removed unnecessary conditions check where no actions happens.
    245739
     740
     741
     742
     743
    246744= 1.2.0 =
     745
     746
    247747* Reverted most functionalities back to v0.6, making the plugin leaner and more lightweight than v1.0.0 to v1.1.0.
     748
     749
    248750* Removed some features to avoid option clutter and to focus on original key features. Complete features can be found on the PRO version. Only upgrade if you don't mind this.
     751
     752
    249753* Removed unnecessary ajax loading spinner on page load.
     754
     755
    250756* Added check for version compatibilty between this plugin and its pro extension. Terminate activation if not compatible.
     757
     758
    251759* Updated i18n.
    252760
     761
     762
     763
     764
    253765= 1.1.0 =
     766
     767
    254768* Added complete-the-look section to default popup template for multiple upsell products.
     769
     770
    255771* Maintained compatibilty with pro version.
    256772
     773
     774
     775
     776
    257777= 1.0.1 =
     778
     779
    258780* Fixed uncaught error caused by deleted upsell products, added check for published product and product post type.
    259781
     782
     783
     784
     785
    260786= 1.0.0 =
     787
     788
    261789* Added support for multiple upsell products per popup.
     790
     791
    262792* Added default template for multiple upsell products popup, making use of Flickity carousel.
     793
     794
    263795* Implemented better UX design for multiple upsell products popup, default template shows product prices and total price of products selected.
     796
     797
    264798* Default template for single upsell popup was improved to include upsell product price and made to match default template for multiple upsell popup.
     799
     800
    265801* Added support for Woocommerce native Linked Products upsells and cross sells.
     802
     803
    266804* Backward compatibilty support added for our classic upsell product meta field.
     805
     806
    267807* Improved product meta box UI and UX.
     808
     809
    268810* JS and CSS files are now minified.
     811
     812
    269813* Maintained responsiveness of popup templates.
     814
     815
    270816* Added loading spinner for ajax actions on popups.
     817
     818
    271819* Prevented popups from firing consecutively after the first popup's added to cart action.
     820
     821
    272822* Init hook changed to wp_loaded hook for non-ajax popup actions, preventing headers already sent error.
    273823
     824
     825
     826
     827
    274828= 0.6 =
     829
     830
    275831* Added an option to change redirection behavior of the popup's no button.
     832
     833
    276834* Improved how plugin product meta data are saved.
     835
     836
    277837* Improved security.
     838
     839
    278840* Added version check for pro add-on.
     841
     842
    279843* Templates text change.
    280844
     845
     846
     847
     848
    281849= 0.5 =
     850
     851
    282852* Added new option for user to change redirection behavior of popups.
     853
     854
    283855* Added new template as default template.
     856
     857
    284858* Improved il8n on templates.
     859
     860
    285861* Modified styles on templates.
    286862
     863
     864
     865
     866
    287867= 0.4 =
     868
     869
    288870* Added support for PRO version.
     871
     872
    289873* Updated translation.
    290874
     875
     876
     877
     878
    291879= 0.3 =
     880
     881
    292882* Added support for internationalization/i18n/translation.
     883
     884
    293885* Localization to Bahasa Melayu.
    294886
     887
     888
     889
     890
    295891= 0.2 =
     892
     893
    296894* Popups are now compatible to be used with add to cart buttons that use AJAX.
     895
     896
    297897* Added another plugin dependency check. Plugin activation fails if Woocommerce is not activated.
     898
     899
    298900* Form in popup templates now has an ID.
    299901
     902
     903
     904
     905
    300906= 0.1 =
     907
     908
    301909* Initial release.
    302910
     911
     912
     913
     914
    303915== Upgrade Notice ==
    304916
     917
     918
     919
     920
    305921= 1.7.4 =
     922
     923
    306924* Woocommerce compatibility.
    307925
     926
     927
     928
     929
    308930= 1.7.6 =
     931
     932
    309933* Multiple quantity options for upsell product global setting for upsell products.
    310934
     935
     936
     937
     938
    311939= 1.7.7 =
     940
     941
    312942* Quantity options and cart price auto update added.
    313943
     944
     945
     946
     947
    314948== Changelog === 1.7.9 =
     949
     950
    315951* Option to display discount coupon code
    316952
     953
     954
     955
     956
    317957== Changelog === 1.8.0 =
     958
     959
    318960* Reference screenshot added
  • very-simple-woocommerce-upsell-popup/trunk/index.php

    r2866829 r2932041  
    11<?php
     2
     3
    24/**
     5
     6
    37 * Plugin Name: Woocommerce Upsell Popup
     8
     9
    410 * Plugin URI: https://woocommerce.upsellpopup.com/
     11
     12
    513 * Description: An upsell & cross-sell popup plugin for Woocommerce. Show unobtrusive and responsive popup to your visitors when they click add to cart button.
    6  * Version: 1.8.7
     14
     15
     16 * Version: 1.8.9
     17
     18
    719 * Author: Upsell Popup
     20
     21
    822 * Author URI: https://woocommerce.upsellpopup.com/
     23
     24
    925 * WC requires at least: 6.0.0
     26
     27
    1028 * WC tested up to: 7.2.2
     29
     30
    1131 * Text Domain: very-simple-woocommerce-upsell-popup
     32
     33
    1234 */
    1335
     36
     37
     38
     39
    1440if ( ! defined( 'ABSPATH' ) ) exit;
     41
     42
    1543define('thp-wc-upsell-popup-frzn', TRUE);
    1644
     45
     46
     47
     48
    1749include ( 'wup-options.php' );
     50
     51
    1852include ( 'wup-metabox.php' );
     53
     54
    1955include ( 'wup-noajax.php' );
    2056
     57
     58
     59
     60
    2161$thp_addtocart_popup_btn = false;
    2262
     63
     64
     65
     66
    2367function thp_wuppro_active() {
     68
     69
    2470    if ( ! function_exists('is_plugin_active')) {
     71
     72
    2573        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    26     }
    27    
     74
     75
     76    }
     77
     78
     79   
     80
     81
    2882    if( is_plugin_active( 'woocommerce-upsell-popup-pro/index.php' ) ) {
     83
     84
    2985        return true; //pro version is active
    30     }
     86
     87
     88    }
     89
     90
    3191return false;
     92
     93
    3294}
    3395
     96
     97
     98
     99
    34100if (thp_wuppro_active()) {
     101
     102
    35103    include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/wuppro-metabox.php' );
     104
     105
    36106}
    37107
    38108
     109
     110
     111
     112
     113
     114
    39115function thp_woocommerce_inactive() {
     116
     117
    40118    if ( ! function_exists('is_plugin_inactive')) {
     119
     120
    41121        require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
    42     }
    43    
     122
     123
     124    }
     125
     126
     127   
     128
     129
    44130    if( is_plugin_inactive( 'woocommerce/woocommerce.php' ) ) {
     131
     132
    45133        return true; //woocommerce is inactive
    46     }
     134
     135
     136    }
     137
     138
    47139return false;
     140
     141
    48142}
    49143
    50144
     145
     146
     147
     148
     149
     150
    51151function thp_wc_upsell_dependency_check() {
     152
     153
    52154    if ( thp_woocommerce_inactive() ) {
     155
     156
    53157       add_action( 'admin_notices', 'thp_wc_upsell_dep_warning' );
     158
     159
    54160       return;
    55     }
    56    
     161
     162
     163    }
     164
     165
     166   
     167
     168
    57169    load_plugin_textdomain( 'very-simple-woocommerce-upsell-popup', false, basename( dirname( __FILE__ ) ) . '/languages' );
     170
     171
    58172}
     173
     174
    59175add_action( 'plugins_loaded', 'thp_wc_upsell_dependency_check' );
    60176
    61177
     178
     179
     180
     181
     182
     183
    62184function thp_wc_upsell_dep_warning() {
     185
     186
    63187    ?>
     188
     189
    64190    <div class="notice notice-error">
     191
     192
    65193        <p><?php _e( "Woocommerce Upsell Popup requires Woocommerce in order for it to work properly!", 'very-simple-woocommerce-upsell-popup' ); ?></p>
     194
     195
    66196    </div>
     197
     198
    67199    <?php
     200
     201
    68202}
    69203
    70204
     205
     206
     207
     208
     209
     210
    71211function thp_wc_upsell_activation_check() {
    72    
     212
     213
     214   
     215
     216
    73217    if ( thp_woocommerce_inactive() ) {
     218
     219
    74220        deactivate_plugins( plugin_basename( __FILE__ ) );
     221
     222
    75223        wp_die( __( "Woocommerce Upsell Popup requires Woocommerce to be active. Please install and activate Woocommerce before trying to activate this plugin again.", 'very-simple-woocommerce-upsell-popup' ) );
    76     }
     224
     225
     226    }
     227
     228
    77229}
     230
     231
    78232register_activation_hook( __FILE__, 'thp_wc_upsell_activation_check' );
    79233
    80234
     235
     236
     237
     238
     239
     240
    81241function thp_wuppro_compatibility_check() {
    82242
     243
     244
     245
     246
    83247 if ( (current_user_can('activate_plugins')) && (!wp_doing_ajax()) ) {
     248
     249
    84250    if ( thp_wuppro_active() ) {
     251
     252
    85253        $thp_wuppro_at_least = '1.1.2';
    86        
     254
     255
     256       
     257
     258
    87259        $thp_wuppro_data = get_plugin_data( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/index.php', false, false );
     260
     261
    88262        $thp_wuppro_user_v = $thp_wuppro_data['Version'];
    89        
     263
     264
     265       
     266
     267
    90268        if ( version_compare($thp_wuppro_user_v, $thp_wuppro_at_least, '<') ) {
    91            
     269
     270
     271           
     272
     273
    92274            deactivate_plugins( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/index.php' );
    93            
     275
     276
     277           
     278
     279
    94280            $url = 'https://woocommerce.upsellpopup.com/my-account/';
    95            
     281
     282
     283           
     284
     285
    96286            $notice_string = sprintf( wp_kses( __( 'The latest version of Woocommerce Upsell Popup is only compatible with Woocommerce Upsell Popup PRO version 1.1.2 or later. Please upgrade PRO to latest version!<br /><br /> Login to <a href="%s" target="_blank" rel="noopener noreferrer">your account</a>  to download the latest version of Woocommerce Upsell Popup PRO.', 'very-simple-woocommerce-upsell-popup' ), array(  'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ), 'br' => array() ) ), esc_url( $url ) );
    97            
     287
     288
     289           
     290
     291
    98292            wp_die( $notice_string );
     293
     294
    99295            exit;
    100         }
    101     }
     296
     297
     298        }
     299
     300
     301    }
     302
     303
    102304 }
     305
     306
    103307}
     308
     309
    104310add_action( 'admin_init', 'thp_wuppro_compatibility_check' );
    105311
    106312
     313
     314
     315
     316
     317
     318
    107319function thp_wuppro_version_check() {
     320
     321
    108322    if ( thp_wuppro_active() ) {
     323
     324
    109325        $thp_wuppro_latest_v = '1.1.2';
    110        
     326
     327
     328       
     329
     330
    111331        $thp_wuppro_data = get_plugin_data( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/index.php', false, false );
     332
     333
    112334        $thp_wuppro_user_v = $thp_wuppro_data['Version'];
    113        
     335
     336
     337       
     338
     339
    114340        if ( version_compare($thp_wuppro_user_v, $thp_wuppro_latest_v, '<') ) {
     341
     342
    115343            $url = 'https://woocommerce.upsellpopup.com/my-account/';
     344
     345
    116346            $notice_string = sprintf( wp_kses( __( 'There is a new update available for Woocommerce Upsell Popup Pro. Please login to <a href="%s" target="_blank" rel="noopener noreferrer">your account</a>  to download the latest version.', 'very-simple-woocommerce-upsell-popup' ), array(  'a' => array( 'href' => array(), 'target' => array(), 'rel' => array() ) ) ), esc_url( $url ) );
     347
     348
    117349            echo '<div class="notice notice-warning is-dismissible">';
     350
     351
    118352            echo '<p>'.$notice_string.'</p>';
     353
     354
    119355            echo '</div>';
    120         }
    121     }
     356
     357
     358        }
     359
     360
     361    }
     362
     363
    122364}
     365
     366
    123367add_action('admin_notices', 'thp_wuppro_version_check');
    124368
    125369
     370
     371
     372
     373
     374
     375
    126376function thp_wup_settings_link( $links ) {
     377
     378
    127379    $settings_link = '<a href="'.esc_url( get_admin_url(null, 'admin.php?page=thp-wup-main-settings') ).'">' .
     380
     381
    128382    esc_html( __( 'Settings', 'very-simple-woocommerce-upsell-popup' ) ) . '</a>';
    129    
     383
     384
     385   
     386
     387
    130388    return array_merge( array( $settings_link ), $links );
     389
     390
    131391}
     392
     393
    132394add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'thp_wup_settings_link' );
    133395
    134396
     397
     398
     399
     400
     401
     402
    135403function thp_popup_frontend_scripts () {
     404
     405
    136406    if (!thp_wuppro_active()) {
    137        
     407
     408
     409       
     410
     411
    138412        $ajax_enabled = get_option( 'woocommerce_enable_ajax_add_to_cart' );
    139        
     413
     414
     415       
     416
     417
    140418        if ( is_shop() || is_product_category() ) {
     419
     420
    141421            if ( 'yes' === $ajax_enabled ) {
     422
     423
    142424                wp_enqueue_script( 'thp-popup-js', plugin_dir_url( __FILE__ ).'js/wup-ajax.min.js', array('jquery'), '', false );
     425
     426
    143427                wp_localize_script( 'thp-popup-js', 'thp_popup_vars', array(
     428
     429
    144430                    'ajaxurl' => admin_url( 'admin-ajax.php' ),
     431
     432
    145433                    'added_to_cart' => __( 'Added to Cart!', 'very-simple-woocommerce-upsell-popup' ),
     434
     435
    146436                    'choose_one' => __( 'Please choose one option!', 'very-simple-woocommerce-upsell-popup' )
     437
     438
    147439                    )
     440
     441
    148442                );
     443
     444
    149445                wp_enqueue_script( 'wup-noajax-js', plugin_dir_url( __FILE__ ).'js/wup-noajax.min.js', array('jquery'), '', false );
    150             }
     446
     447
     448            }
     449
     450
    151451            else {
     452
     453
    152454                wp_enqueue_script( 'wup-noajax-js', plugin_dir_url( __FILE__ ).'js/wup-noajax.min.js', array('jquery'), '', false );
     455
     456
    153457                wp_localize_script( 'wup-noajax-js', 'wup_noajax_js_vars', array(
     458
     459
    154460                    'choose_one' => __( 'Please choose one option!', 'very-simple-woocommerce-upsell-popup' )
     461
     462
    155463                    )
     464
     465
    156466                );
    157             }
    158         }
     467
     468
     469            }
     470
     471
     472        }
     473
     474
    159475        elseif ( is_product() ) {
    160            
     476
     477
     478           
     479
     480
    161481            $wup_options = ( !empty(get_option( 'thp_wup_options' )) ? get_option( 'thp_wup_options' ) : '' );
     482
     483
    162484            $ajax_off = ( !empty($wup_options['ajax_off']) ? $wup_options['ajax_off'] : '' );
    163            
     485
     486
     487           
     488
     489
    164490            if (!$ajax_off) { //ajax enabled
     491
     492
    165493               
     494
     495
    166496                wp_enqueue_script( 'thp-popup-js', plugin_dir_url( __FILE__ ).'js/wup-ajax.min.js', array('jquery'), '', false );
     497
     498
    167499                wp_localize_script( 'thp-popup-js', 'thp_popup_vars', array(
     500
     501
    168502                    'ajaxurl' => admin_url( 'admin-ajax.php' ),
     503
     504
    169505                    'added_to_cart' => __( 'Added to Cart!', 'very-simple-woocommerce-upsell-popup' ),
     506
     507
    170508                    'choose_one' => __( 'Please choose one option!', 'very-simple-woocommerce-upsell-popup' )
     509
     510
    171511                    )
     512
     513
    172514                );
     515
     516
    173517               
     518
     519
    174520                wp_enqueue_script( 'wup-noajax-js', plugin_dir_url( __FILE__ ).'js/wup-noajax.min.js', array('jquery'), '', false );
     521
     522
    175523               
     524
     525
    176526                $use_wc_ajax = ( !empty($wup_options['use_wc_ajax']) ? $wup_options['use_wc_ajax'] : '' );
     527
     528
    177529               
     530
     531
    178532                if ( (!$use_wc_ajax) && (!wp_script_is( 'woo-ajax-add-to-cart', 'enqueued' )) ) //uses quadlayers
     533
     534
    179535                    wp_enqueue_script( 'woo-ajax-add-to-cart', plugin_dir_url( __FILE__ ).'js/quadlayers-ajax-add-to-cart.min.js', array('jquery', 'wc-add-to-cart'), '', true );
     536
     537
    180538                elseif ($use_wc_ajax) //uses wc
     539
     540
    181541                    wp_enqueue_script( 'wup-woo-ajax-add-to-cart', plugin_dir_url( __FILE__ ).'js/ajaxified.min.js', array('jquery', 'wc-add-to-cart'), '', true );
    182             }
     542
     543
     544            }
     545
     546
    183547            elseif ($ajax_off) { //ajax disabled
     548
     549
    184550                wp_enqueue_script( 'wup-noajax-js', plugin_dir_url( __FILE__ ).'js/wup-noajax.min.js', array('jquery'), '', false );
     551
     552
    185553                wp_localize_script( 'wup-noajax-js', 'wup_noajax_js_vars', array(
     554
     555
    186556                    'choose_one' => __( 'Please choose one option!', 'very-simple-woocommerce-upsell-popup' )
     557
     558
    187559                    )
     560
     561
    188562                );
    189             }
    190         }
    191     }
     563
     564
     565            }
     566
     567
     568        }
     569
     570
     571    }
     572
     573
    192574}
     575
     576
    193577add_action( 'wp_enqueue_scripts', 'thp_popup_frontend_scripts' );
    194578
    195579
     580
     581
     582
     583
     584
     585
    196586function thp_wup_ajax_add_to_cart_handler() {
     587
     588
    197589    WC_Form_Handler::add_to_cart_action();
     590
     591
    198592    WC_AJAX::get_refreshed_fragments();
     593
     594
    199595}
     596
     597
    200598add_action( 'wc_ajax_thp_wup_add_to_cart', 'thp_wup_ajax_add_to_cart_handler' );
     599
     600
    201601add_action( 'wc_ajax_nopriv_thp_wup_add_to_cart', 'thp_wup_ajax_add_to_cart_handler' );
    202602
    203603
     604
     605
     606
     607
     608
     609
    204610function thp_wup_remove_action_for_wc_handler() {
    205    
     611
     612
     613   
     614
     615
    206616    $wup_options = ( !empty(get_option( 'thp_wup_options' )) ? get_option( 'thp_wup_options' ) : '' );
     617
     618
    207619    $ajax_off = ( !empty($wup_options['ajax_off']) ? $wup_options['ajax_off'] : '' );
    208    
     620
     621
     622   
     623
     624
    209625    if ($ajax_off)
     626
     627
    210628        return;
    211    
     629
     630
     631   
     632
     633
    212634    $use_wc_ajax = ( !empty($wup_options['use_wc_ajax']) ? $wup_options['use_wc_ajax'] : '' );
    213    
     635
     636
     637   
     638
     639
    214640    if (! $use_wc_ajax) {
     641
     642
    215643        return;
    216     }
     644
     645
     646    }
     647
     648
    217649    else if ( ($use_wc_ajax) && (is_ajax()) && (! is_admin()) ) {
     650
     651
    218652        remove_action( 'wp_loaded', array( 'WC_Form_Handler', 'add_to_cart_action' ), 20 );
    219     }
     653
     654
     655    }
     656
     657
     658
     659
    220660
    221661}
     662
     663
    222664add_action( 'init', 'thp_wup_remove_action_for_wc_handler' );
    223665
    224666
     667
     668
     669
     670
     671
     672
    225673function thp_upsell_backend_scripts( $hook ) {
     674
     675
    226676    global $post;
    227677
     678
     679
     680
     681
    228682    if ( ($hook == 'post-new.php') || ($hook == 'post.php') || (@$_REQUEST['page'] == 'thp-wup-main-settings')) {
     683
     684
    229685        if ( ('product' === @$post->post_type) || (@$_REQUEST['page'] == 'thp-wup-main-settings')) { 
     686
     687
    230688            wp_enqueue_style( 'thp-select2-css', plugin_dir_url( __FILE__ ).'css/select2.min.css' );
     689
     690
    231691            wp_enqueue_style( 'thp-upsell-admin-css', plugin_dir_url( __FILE__ ).'css/wup-admin-style.min.css' );                       wp_enqueue_style( 'wp-color-picker' );         
     692
     693
    232694            wp_enqueue_script( 'my-script-handle', plugin_dir_url( __FILE__ ).'js/flytonic_color_picker.js', array( 'wp-color-picker' ), false, true);
     695
     696
    233697            wp_enqueue_script( 'thp-select2-js', plugin_dir_url( __FILE__ ).'js/select2.min.js', array( 'jquery' ), '4.0.3', true );
     698
     699
    234700            wp_enqueue_script( 'thp-upsell-admin-js', plugin_dir_url( __FILE__ ).'js/product-search.min.js', array( 'jquery' ), false, true );
     701
     702
    235703            wp_localize_script('thp-upsell-admin-js', 'thp_upsellmetabox_vars', array(
     704
     705
    236706                'select2_searchproduct_placeholder' => __( 'Search for product name..', 'very-simple-woocommerce-upsell-popup' ),
     707
     708
    237709                'select2_template_placeholder' => __( 'Choose template..', 'very-simple-woocommerce-upsell-popup' ),
     710
     711
    238712                'select2_redirect_placeholder' => __( 'Choose behavior..', 'very-simple-woocommerce-upsell-popup' )
     713
     714
    239715                )
     716
     717
    240718            );
     719
     720
    241721        }
     722
     723
    242724    }
     725
     726
    243727}
     728
     729
    244730add_action( 'admin_enqueue_scripts', 'thp_upsell_backend_scripts', 10, 1 );
    245731
    246732
     733
     734
     735
     736
     737
     738
    247739function thp_search_product_to_upsell() {
     740
     741
    248742    if ( ! current_user_can( 'manage_options' ) ) {
     743
     744
    249745        return;
    250     }
     746
     747
     748    }
     749
     750
     751
     752
    251753
    252754        ob_start();
    253755
     756
     757
     758
     759
    254760        $thp_search_term = filter_input( INPUT_GET, 'thp_search_term', FILTER_SANITIZE_STRING );
     761
     762
    255763        $thp_current_prod_id    = filter_input( INPUT_GET, 'thp_current_prod_id', FILTER_SANITIZE_NUMBER_INT );
    256764
     765
     766
     767
     768
    257769        if ( empty( $thp_search_term ) ) {
     770
     771
    258772            die();
    259         }
     773
     774
     775        }
     776
     777
    260778        $arg            = array(
     779
     780
    261781            'post_status'    => 'publish',
     782
     783
    262784            'post_type'      => 'product',
     785
     786
    263787            'posts_per_page' => 50,
     788
     789
    264790            's'              => $thp_search_term,
     791
     792
    265793            'post__not_in'   => array( $thp_current_prod_id )
     794
     795
    266796        );
     797
     798
    267799        $the_query      = new WP_Query( $arg );
     800
     801
    268802        $found_products = array();
     803
     804
    269805        if ( $the_query->have_posts() ) {
     806
     807
    270808            while ( $the_query->have_posts() ) {
     809
     810
    271811                $the_query->the_post();
     812
     813
    272814                $_product = wc_get_product( get_the_ID() );
     815
     816
    273817               
     818
     819
    274820                $product          = array(
     821
     822
    275823                    'id'   => $_product->get_id(),
     824
     825
    276826                    'text' => get_the_title() . ' (ID:' . get_the_ID() . ')'
     827
     828
    277829                );
     830
     831
    278832                $found_products[] = $product;
    279             }
    280         }
    281        
     833
     834
     835            }
     836
     837
     838        }
     839
     840
     841       
     842
     843
    282844        wp_reset_postdata();
     845
     846
    283847        wp_send_json( $found_products );
     848
     849
    284850        die();
     851
     852
    285853}
     854
     855
    286856add_action( 'wp_ajax_thp_search_product_to_upsell', 'thp_search_product_to_upsell' );
    287857
    288858
     859
     860
     861
     862
     863
     864
    289865function thp_fire_php_include($product_id) {
    290    
     866
     867
     868   
     869
     870
    291871    $wup_options = ( !empty(get_option( 'thp_wup_options' )) ? get_option( 'thp_wup_options' ) : '' );
     872
     873
    292874    /*$global_settings_on = ( !empty($wup_options['global_settings_on']) ? $wup_options['global_settings_on'] : '' );*/
     875
     876
    293877    $individual_settings_on = ( !empty(get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true)) ? get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true) : '' );
     878
     879
    294880    $cat_settings_on = ( !empty($wup_options['cat_settings_on']) ? $wup_options['cat_settings_on'] : '' );
    295    
     881
     882
     883   
     884
     885
    296886    /*if ($global_settings_on) {
     887
     888
    297889        $global_upsell_enabled = ( !empty($wup_options['enable_upsell_global']) ? $wup_options['enable_upsell_global'] : '' );
    298        
     890
     891
     892       
     893
     894
    299895        if (!$global_upsell_enabled)
     896
     897
    300898            return;
     899
     900
    301901    }*/
     902
     903
    302904    if($individual_settings_on){
     905
     906
    303907        if(!empty(get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true))){
     908
     909
    304910            $single_upsell_enabled = get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true);
    305            
     911
     912
     913           
     914
     915
    306916            if (!$single_upsell_enabled)
     917
     918
    307919                return;
    308         }
    309     }
     920
     921
     922        }
     923
     924
     925    }
     926
     927
    310928    else if ($cat_settings_on) {
    311        
     929
     930
     931       
     932
     933
    312934        $new_cat_ids = array();
     935
     936
    313937        $cat_list_ids = wp_get_post_terms($product_id, 'product_cat', array('fields'=>'ids'));
    314        
     938
     939
     940       
     941
     942
    315943        foreach ($cat_list_ids as $cat_list_id) {
    316            
     944
     945
     946           
     947
     948
    317949            $cat_info = get_term_by('id', $cat_list_id, 'product_cat');
     950
     951
    318952            $cat_name = $cat_info->name;
    319            
     953
     954
     955           
     956
     957
    320958            /*if ($cat_info->parent) {
     959
     960
    321961                $cat_list_id = $cat_info->parent;
     962
     963
    322964                $parent_info = get_term_by('id', $cat_list_id, 'product_cat');
     965
     966
    323967                $cat_name = $parent_info->name;
    324             }
     968
     969
     970            }
     971
     972
    325973            echo '<pre>'; print_r($cat_info); die;*/
     974
     975
    326976            $new_cat_ids[$cat_list_id] = $cat_name;
    327         }
    328        
     977
     978
     979        }
     980
     981
     982       
     983
     984
    329985        asort($new_cat_ids); //sort by category name in ascending order
    330        
     986
     987
     988       
     989
     990
    331991        reset($new_cat_ids);
    332        
     992
     993
     994       
     995
     996
    333997        $cat_id = key($new_cat_ids); //first category ID
    334998
     999
     1000
     1001
     1002
    3351003        $cat_upsell_enabled = ( !empty($wup_options['enable_upsell_cat'.@$cat_id]) ? $wup_options['enable_upsell_cat'.@$cat_id] : '' );
    336        
     1004
     1005
     1006       
     1007
     1008
    3371009        if (!$cat_upsell_enabled)
     1010
     1011
    3381012            return;
     1013
     1014
    3391015    }else{
     1016
     1017
    3401018        $global_upsell_enabled = ( !empty($wup_options['enable_upsell_global']) ? $wup_options['enable_upsell_global'] : '' );
    341        
     1019
     1020
     1021       
     1022
     1023
    3421024        if (!$global_upsell_enabled)
     1025
     1026
    3431027            return;
    344     }
     1028
     1029
     1030    }
     1031
     1032
    3451033    /*else {
     1034
     1035
    3461036        if(!empty(get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true))){
     1037
     1038
    3471039            $single_upsell_enabled = get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true);
    348            
     1040
     1041
     1042           
     1043
     1044
    3491045            if (!$single_upsell_enabled)
     1046
     1047
    3501048                return;
    351         }
     1049
     1050
     1051        }
     1052
     1053
    3521054    }*/
    353    
     1055
     1056
     1057   
     1058
     1059
    3541060    $thp_upsell_prod_ids = array();
     1061
     1062
    3551063    $thp_classic_enabled = '';
     1064
     1065
    3561066    $thp_linked_upsells_enabled = '';
     1067
     1068
    3571069    $thp_classic_prodid = get_post_meta($product_id, 'thp_upsell_product_select', true);
    358    
     1070
     1071
     1072   
     1073
     1074
    3591075    if (thp_wuppro_active()) {
    360        
     1076
     1077
     1078       
     1079
     1080
    3611081        if ($individual_settings_on) {
     1082
     1083
    3621084            $thp_linked_upsells_enabled = get_post_meta($product_id, 'thp_wc_linkedprods_upsells', true);
     1085
     1086
    3631087            $thp_classic_enabled = get_post_meta($product_id, 'thp_classic_single_upsell', true);
    364            
     1088
     1089
     1090           
     1091
     1092
    3651093            if ($thp_classic_enabled && $thp_classic_prodid) {
     1094
     1095
    3661096               
     1097
     1098
    3671099                $classic_obj = new WC_Product($thp_classic_prodid);
     1100
     1101
    3681102               
     1103
     1104
    3691105                if ( ( 'publish' == get_post_status ( $thp_classic_prodid ) ) && ( get_post_type( $thp_classic_prodid ) == 'product' ) && ( $classic_obj->is_in_stock() ) ) {
     1106
     1107
    3701108                    $thp_upsell_prod_ids[] = $thp_classic_prodid;
     1109
     1110
    3711111                }
    372             }
    373         }
     1112
     1113
     1114            }
     1115
     1116
     1117        }
     1118
     1119
    3741120        else if ($cat_settings_on) {
     1121
     1122
    3751123            $thp_linked_upsells_enabled = ( !empty($wup_options['linkedprods_upsells_cat'.@$cat_id]) ? $wup_options['linkedprods_upsells_cat'.@$cat_id] : '' );
    376         }
     1124
     1125
     1126        }
     1127
     1128
    3771129        else {
     1130
     1131
    3781132            $thp_linked_upsells_enabled = ( !empty($wup_options['linkedprods_upsells_global']) ? $wup_options['linkedprods_upsells_global'] : '' );
    379            
    380         }
    381        
     1133
     1134
     1135           
     1136
     1137
     1138        }
     1139
     1140
     1141       
     1142
     1143
    3821144        /*if ($global_settings_on) {
     1145
     1146
    3831147            $thp_linked_upsells_enabled = ( !empty($wup_options['linkedprods_upsells_global']) ? $wup_options['linkedprods_upsells_global'] : '' );
    384         }
     1148
     1149
     1150        }
     1151
     1152
    3851153        else if ($cat_settings_on) {
     1154
     1155
    3861156            $thp_linked_upsells_enabled = ( !empty($wup_options['linkedprods_upsells_cat'.@$cat_id]) ? $wup_options['linkedprods_upsells_cat'.@$cat_id] : '' );
    387         }
     1157
     1158
     1159        }
     1160
     1161
    3881162        else {
     1163
     1164
    3891165            $thp_linked_upsells_enabled = get_post_meta($product_id, 'thp_wc_linkedprods_upsells', true);
     1166
     1167
    3901168            $thp_classic_enabled = get_post_meta($product_id, 'thp_classic_single_upsell', true);
    391            
     1169
     1170
     1171           
     1172
     1173
    3921174            if ($thp_classic_enabled && $thp_classic_prodid) {
     1175
     1176
    3931177               
     1178
     1179
    3941180                $classic_obj = new WC_Product($thp_classic_prodid);
     1181
     1182
    3951183               
     1184
     1185
    3961186                if ( ( 'publish' == get_post_status ( $thp_classic_prodid ) ) && ( get_post_type( $thp_classic_prodid ) == 'product' ) && ( $classic_obj->is_in_stock() ) ) {
     1187
     1188
    3971189                    $thp_upsell_prod_ids[] = $thp_classic_prodid;
     1190
     1191
    3981192                }
    399             }
     1193
     1194
     1195            }
     1196
     1197
    4001198        }*/ //end if else
    401        
     1199
     1200
     1201       
     1202
     1203
    4021204        $product_obj = '';
    403        
     1205
     1206
     1207       
     1208
     1209
    4041210        if ($thp_linked_upsells_enabled==1) {
     1211
     1212
    4051213            $product_obj = new WC_Product($product_id);
    406            
     1214
     1215
     1216           
     1217
     1218
    4071219            $wc_upsell_ids = $product_obj->get_upsell_ids();
     1220
     1221
    4081222            $single_upsell_enabled = get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true);
    409            
     1223
     1224
     1225           
     1226
     1227
    4101228            $global_settings_on = ( !empty($wup_options['global_settings_on']) ? $wup_options['global_settings_on'] : '' );
     1229
     1230
    4111231            $global_upsell_enabled = ( !empty($wup_options['enable_upsell_global']) ? $wup_options['enable_upsell_global'] : '' );
     1232
     1233
    4121234            $list_of_global_upsell_products = ( !empty($wup_options['list_of_global_upsell_products']) ? $wup_options['list_of_global_upsell_products'] : '' );
    413            
     1235
     1236
     1237           
     1238
     1239
    4141240            $cat_settings_on = ( !empty($wup_options['cat_settings_on']) ? $wup_options['cat_settings_on'] : '' );
     1241
     1242
    4151243            $list_of_global_upsell_products_cat = ( !empty($wup_options['list_of_global_upsell_products_cat'.@$cat_id]) ? $wup_options['list_of_global_upsell_products_cat'.@$cat_id] : '' );
     1244
     1245
    4161246            $cat_upsell_enabled = ( !empty($wup_options['enable_upsell_cat'.@$cat_id]) ? $wup_options['enable_upsell_cat'.@$cat_id] : '' );
    417            
     1247
     1248
     1249           
     1250
     1251
    4181252            if ((!empty($wc_upsell_ids)) && (!empty($single_upsell_enabled))) {
     1253
     1254
    4191255                foreach ( $wc_upsell_ids as $upsell_id ) {
     1256
     1257
    4201258                    if ( ( get_post_type( $upsell_id ) == 'product' ) && ( 'publish' == get_post_status ( $upsell_id ) ) ) {
     1259
     1260
    4211261                        $upsell_obj = new WC_Product($upsell_id);
     1262
     1263
    4221264                        if ( $upsell_obj->is_in_stock() )
     1265
     1266
    4231267                            $thp_upsell_prod_ids[] = $upsell_id;
     1268
     1269
    4241270                    }
     1271
     1272
    4251273                    elseif ( get_post_type( $upsell_id ) == 'product_variation' ) {
     1274
     1275
    4261276                        $upsell_variation_obj = new WC_Product_Variation($upsell_id);
     1277
     1278
    4271279                       
     1280
     1281
    4281282                        if ( ($upsell_variation_obj->is_in_stock()) && (wp_get_post_parent_id( $upsell_id ) != false) )
     1283
     1284
    4291285                            $thp_upsell_prod_ids[] = $upsell_id;
     1286
     1287
    4301288                    }
     1289
     1290
    4311291                }
     1292
     1293
    4321294            }else if((!empty($list_of_global_upsell_products_cat)) && (!empty($cat_upsell_enabled)) && (!empty($cat_settings_on))){
     1295
     1296
    4331297                foreach ( $list_of_global_upsell_products_cat as $upsell_id ) {
     1298
     1299
    4341300                    $thp_upsell_prod_ids[] = $upsell_id;
     1301
     1302
    4351303                }
     1304
     1305
    4361306            }else if((!empty($list_of_global_upsell_products)) && (!empty($global_upsell_enabled)) && (!empty($global_settings_on))){
     1307
     1308
    4371309                foreach ( $list_of_global_upsell_products as $upsell_id ) {
     1310
     1311
    4381312                    $thp_upsell_prod_ids[] = $upsell_id;
     1313
     1314
    4391315                }
    440             }
    441         }
    442        
     1316
     1317
     1318            }
     1319
     1320
     1321        }
     1322
     1323
     1324       
     1325
     1326
    4431327        if ($thp_linked_upsells_enabled==2) {
    444            
     1328
     1329
     1330           
     1331
     1332
    4451333            $global_upsell_enabled = ( !empty($wup_options['enable_upsell_global']) ? $wup_options['enable_upsell_global'] : '' );
     1334
     1335
    4461336            $global_settings_on = ( !empty($wup_options['global_settings_on']) ? $wup_options['global_settings_on'] : '' );
     1337
     1338
    4471339            $list_of_global_cross_upsell_products = ( !empty($wup_options['list_of_global_cross_upsell_products']) ? $wup_options['list_of_global_cross_upsell_products'] : '' );
    448            
     1340
     1341
     1342           
     1343
     1344
    4491345            $cat_settings_on = ( !empty($wup_options['cat_settings_on']) ? $wup_options['cat_settings_on'] : '' );
     1346
     1347
    4501348            $list_of_global_cross_upsell_products_cat = ( !empty($wup_options['list_of_global_cross_upsell_products_cat'.@$cat_id]) ? $wup_options['list_of_global_cross_upsell_products_cat'.@$cat_id] : '' );
     1349
     1350
    4511351            $cat_upsell_enabled = ( !empty($wup_options['enable_upsell_cat'.@$cat_id]) ? $wup_options['enable_upsell_cat'.@$cat_id] : '' );
    452            
     1352
     1353
     1354           
     1355
     1356
    4531357            if (! is_object($product_obj))
     1358
     1359
    4541360                $product_obj = new WC_Product($product_id);
    455            
     1361
     1362
     1363           
     1364
     1365
    4561366            $wc_crosssell_ids = $product_obj->get_cross_sell_ids();
     1367
     1368
    4571369            $single_upsell_enabled = get_post_meta($product_id, 'thp_wc_enable_upsell_on_single_product', true);
    458            
     1370
     1371
     1372           
     1373
     1374
    4591375            if ((!empty($wc_crosssell_ids)) && (!empty($single_upsell_enabled))) {
     1376
     1377
    4601378                foreach ( $wc_crosssell_ids as $crosssell_id ) {
     1379
     1380
    4611381                    if ( ( get_post_type( $crosssell_id ) == 'product' ) && ( 'publish' == get_post_status ( $crosssell_id ) ) ) {
     1382
     1383
    4621384                        $crosssell_obj = new WC_Product($crosssell_id);
     1385
     1386
    4631387                        if ( $crosssell_obj->is_in_stock() )
     1388
     1389
    4641390                            $thp_upsell_prod_ids[] = $crosssell_id;
     1391
     1392
    4651393                    }
     1394
     1395
    4661396                    elseif ( get_post_type( $crosssell_id ) == 'product_variation' ) {
     1397
     1398
    4671399                        $crosssell_variation_obj = new WC_Product_Variation($crosssell_id);
     1400
     1401
    4681402                       
     1403
     1404
    4691405                        if ( ($crosssell_variation_obj->is_in_stock()) && (wp_get_post_parent_id( $crosssell_id ) != false) )
     1406
     1407
    4701408                            $thp_upsell_prod_ids[] = $crosssell_id;
     1409
     1410
    4711411                    }
     1412
     1413
    4721414                }
     1415
     1416
    4731417            }else if((!empty($list_of_global_cross_upsell_products_cat)) && (!empty($cat_upsell_enabled)) && (!empty($cat_settings_on))){               
    474            
     1418
     1419
     1420           
     1421
     1422
    4751423                foreach ( $list_of_global_cross_upsell_products_cat as $upsell_id ) {                   
     1424
     1425
    4761426               
     1427
     1428
    4771429                $thp_upsell_prod_ids[] = $upsell_id;               
     1430
     1431
    4781432               
     1433
     1434
    4791435                }           
    480            
     1436
     1437
     1438           
     1439
     1440
    4811441            }else if((!empty($list_of_global_cross_upsell_products)) && (!empty($global_upsell_enabled)) && (!empty($global_settings_on))){             
    482            
     1442
     1443
     1444           
     1445
     1446
    4831447                foreach ( $list_of_global_cross_upsell_products as $upsell_id ) {                   
     1448
     1449
    4841450               
     1451
     1452
    4851453                $thp_upsell_prod_ids[] = $upsell_id;               
     1454
     1455
    4861456               
     1457
     1458
    4871459                }           
    488            
    489             }
    490         }
    491        
     1460
     1461
     1462           
     1463
     1464
     1465            }
     1466
     1467
     1468        }
     1469
     1470
     1471       
     1472
     1473
    4921474        $thp_upsell_prod_ids = array_unique($thp_upsell_prod_ids);
    493     }
     1475
     1476
     1477    }
     1478
     1479
    4941480    elseif (!thp_wuppro_active()) {
     1481
     1482
    4951483        if ($thp_classic_prodid) {
    496            
     1484
     1485
     1486           
     1487
     1488
    4971489            $classic_obj = new WC_Product($thp_classic_prodid);
    498            
     1490
     1491
     1492           
     1493
     1494
    4991495            if ( ( 'publish' == get_post_status ( $thp_classic_prodid ) ) && ( get_post_type( $thp_classic_prodid ) == 'product' ) && ( $classic_obj->is_in_stock() ) ) {
     1496
     1497
    5001498                $thp_upsell_prod_ids[] = $thp_classic_prodid;
    501             }
    502            
     1499
     1500
     1501            }
     1502
     1503
     1504           
     1505
     1506
    5031507            if (! $thp_upsell_prod_ids)
     1508
     1509
    5041510                return;
    505         }
    506     }
    507    
     1511
     1512
     1513        }
     1514
     1515
     1516    }
     1517
     1518
     1519   
     1520
     1521
    5081522    if ( (! $thp_upsell_prod_ids) && (! $thp_classic_prodid) )
     1523
     1524
    5091525        return;
    510    
     1526
     1527
     1528   
     1529
     1530
    5111531    if (is_ajax()) //reminder: is_ajax is woocommerce function, not wordpress
     1532
     1533
    5121534        $popup = '';
    513    
     1535
     1536
     1537   
     1538
     1539
    5141540    if ( ( sizeof($thp_upsell_prod_ids) == 1 ) || ( $thp_classic_prodid && !$thp_classic_enabled && !$thp_linked_upsells_enabled ) ) { //backward compatibilty
     1541
     1542
    5151543        $found = false;
     1544
     1545
    5161546       
     1547
     1548
    5171549        if ($thp_upsell_prod_ids)
     1550
     1551
    5181552            $single_upsell_id = $thp_upsell_prod_ids[0];
     1553
     1554
    5191555        elseif (!$thp_upsell_prod_ids && $thp_classic_prodid)
     1556
     1557
    5201558            $single_upsell_id = $thp_classic_prodid;
    521        
     1559
     1560
     1561       
     1562
     1563
    5221564        if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
     1565
     1566
    5231567            foreach ( WC()->cart->get_cart() as $cart_item => $values ) {
     1568
     1569
    5241570                $_product = $values['data'];
     1571
     1572
    5251573                if ( $_product->get_id() == $single_upsell_id ) {
     1574
     1575
    5261576                    $found = true; //product to upsell found in cart, no need to show popup
     1577
     1578
    5271579                }
    528             }
    529         }
     1580
     1581
     1582            }
     1583
     1584
     1585        }
     1586
     1587
    5301588        if ( ! $found ) {
     1589
     1590
    5311591            global $woocommerce;
     1592
     1593
    5321594            $woocommerce->session->set_customer_session_cookie(true);
    533            
     1595
     1596
     1597           
     1598
     1599
    5341600            $thp_popup_template = get_post_meta($product_id, 'thp_upsellpopup_template', true);
    535            
     1601
     1602
     1603           
     1604
     1605
    5361606            if (is_ajax())
     1607
     1608
    5371609                ob_start();
    538            
     1610
     1611
     1612           
     1613
     1614
    5391615            if ( ($thp_popup_template) && (thp_wuppro_active()) && (strpos($thp_popup_template, 'protemp') !== false) ) {
     1616
     1617
    5401618                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-custom.php' );
    541             }
     1619
     1620
     1621            }
     1622
     1623
    5421624            elseif ( ($thp_popup_template) && (thp_wuppro_active()) && ($thp_popup_template == 'template5') ) { //will deprecate soon
     1625
     1626
    5431627                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template5.php' );
    544             }
     1628
     1629
     1630            }
     1631
     1632
    5451633            elseif ( ($thp_popup_template) && ($thp_popup_template != 'template5') && ($thp_popup_template != 'template-default') && (strpos($thp_popup_template, 'protemp') === false) ) {
     1634
     1635
    5461636                include ( 'templates/single/thp-popup-'.$thp_popup_template.'.php' );
    547             }
     1637
     1638
     1639            }
     1640
     1641
    5481642            else {
     1643
     1644
    5491645                include ( 'templates/single/thp-popup-template-default.php' );
    550             }
    551            
     1646
     1647
     1648            }
     1649
     1650
     1651           
     1652
     1653
    5521654            if (is_ajax())
     1655
     1656
    5531657                $popup = ob_get_clean();
    554         }
    555     }
     1658
     1659
     1660        }
     1661
     1662
     1663    }
     1664
     1665
    5561666    elseif ( sizeof($thp_upsell_prod_ids) > 1 ) {
     1667
     1668
    5571669        global $woocommerce;
     1670
     1671
    5581672        $woocommerce->session->set_customer_session_cookie(true);
    559        
     1673
     1674
     1675       
     1676
     1677
    5601678        $thp_popup_template = get_post_meta($product_id, 'thp_upsellpopup_template_multiple', true);
    561        
     1679
     1680
     1681       
     1682
     1683
    5621684        if (is_ajax())
     1685
     1686
    5631687            ob_start();
    564        
     1688
     1689
     1690       
     1691
     1692
    5651693        if ($thp_popup_template) {
    566            
     1694
     1695
     1696           
     1697
     1698
    5671699            if ( $thp_popup_template == 'template-default' ) {
     1700
     1701
    5681702                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-default-mult.php' );
    569             }
     1703
     1704
     1705            }
     1706
     1707
    5701708            elseif ($thp_popup_template == 'template-radio') {
     1709
     1710
    5711711                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-radio-mult.php' );
    572             }
     1712
     1713
     1714            }
     1715
     1716
    5731717            elseif ($thp_popup_template == 'template-yesno') {
     1718
     1719
    5741720                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-yesno-btn-mult.php' );
    575             }
     1721
     1722
     1723            }
     1724
     1725
    5761726            elseif ($thp_popup_template == 'template-variable') {
     1727
     1728
    5771729                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-variable-mult.php' );
    578             }
     1730
     1731
     1732            }
     1733
     1734
    5791735            elseif ($thp_popup_template == 'template-fc') {
     1736
     1737
    5801738                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-fc-mult.php' );
    581             }
     1739
     1740
     1741            }
     1742
     1743
    5821744            elseif ($thp_popup_template == 'template-variablefc') {
     1745
     1746
    5831747                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-variable-fc-mult.php' );
    584             }
     1748
     1749
     1750            }
     1751
     1752
    5851753            elseif ( strpos($thp_popup_template, '.php') ) {
     1754
     1755
    5861756               
     1757
     1758
    5871759                $thp_popup_template = filter_var( $thp_popup_template, FILTER_SANITIZE_STRING);
     1760
     1761
    5881762                $thp_popup_template = pathinfo($thp_popup_template, PATHINFO_BASENAME);
     1763
     1764
    5891765               
     1766
     1767
    5901768                if ( file_exists( get_stylesheet_directory() . '/wuppro/multiple/' . $thp_popup_template ) )
     1769
     1770
    5911771                    include ( get_stylesheet_directory() . '/wuppro/multiple/' . $thp_popup_template );
     1772
     1773
    5921774                else //if file does not exist
     1775
     1776
    5931777                    include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-default-mult.php' );
    594             }
     1778
     1779
     1780            }
     1781
     1782
    5951783            else {
     1784
     1785
    5961786                include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-default-mult.php' );
    597             }
    598            
    599         }
     1787
     1788
     1789            }
     1790
     1791
     1792           
     1793
     1794
     1795        }
     1796
     1797
    6001798        else {
     1799
     1800
    6011801            include ( plugin_dir_path( __DIR__ ).'woocommerce-upsell-popup-pro/templates/thp-popup-template-default-mult.php' );
    602         }
    603        
     1802
     1803
     1804        }
     1805
     1806
     1807       
     1808
     1809
    6041810        if (is_ajax())
     1811
     1812
    6051813            $popup = ob_get_clean();
    606     }
     1814
     1815
     1816    }
     1817
     1818
     1819
     1820
    6071821
    6081822if (is_ajax())
     1823
     1824
    6091825    return $popup;
     1826
     1827
    6101828}
    6111829
    6121830
     1831
     1832
     1833
     1834
     1835
     1836
    6131837function thp_ajax_popup_trigger() {
     1838
     1839
    6141840    $product_id = filter_input( INPUT_GET, 'prod_id', FILTER_SANITIZE_NUMBER_INT );
     1841
     1842
    6151843    $popup = thp_fire_php_include($product_id);
    616    
     1844
     1845
     1846   
     1847
     1848
    6171849    echo $popup;
     1850
     1851
    6181852    die();
     1853
     1854
    6191855}
     1856
     1857
    6201858add_action('wp_ajax_nopriv_thp_ajax_popup_trigger', 'thp_ajax_popup_trigger');
     1859
     1860
    6211861add_action('wp_ajax_thp_ajax_popup_trigger', 'thp_ajax_popup_trigger');
    6221862
    6231863
     1864
     1865
     1866
     1867
     1868
     1869
    6241870function thp_popup_form_action_ajax () {
    625    
     1871
     1872
     1873   
     1874
     1875
    6261876    $clicked = filter_input( INPUT_GET, 'clicked', FILTER_SANITIZE_STRING );
     1877
     1878
    6271879    $product_id = filter_input( INPUT_GET, 'prod_id', FILTER_SANITIZE_NUMBER_INT );
     1880
     1881
    6281882    $redirect_url = '';
    629    
     1883
     1884
     1885   
     1886
     1887
    6301888    if ($clicked == 'yes') {
    631        
     1889
     1890
     1891       
     1892
     1893
    6321894        $upsell_product_id = filter_input( INPUT_GET, 'up_pid', FILTER_SANITIZE_NUMBER_INT );
    633        
     1895
     1896
     1897       
     1898
     1899
    6341900        if ( get_post_type( $upsell_product_id ) == 'product' )
     1901
     1902
    6351903            $_product = wc_get_product( $upsell_product_id );
    636        
     1904
     1905
     1906       
     1907
     1908
    6371909        if (( get_post_type( $upsell_product_id ) == 'product_variation' ) || ( $_product->is_type( 'simple' ) ) || ( $_product->is_type( 'course' ) )) {
     1910
     1911
    6381912            //WC()->cart->add_to_cart( $upsell_product_id );
     1913
     1914
    6391915            if(isset($_REQUEST['quality-'.$upsell_product_id.''])){
     1916
     1917
    6401918                WC()->cart->add_to_cart( $upsell_product_id,$_REQUEST['quality-'.$upsell_product_id.''] );
     1919
     1920
    6411921            }else{
     1922
     1923
    6421924                WC()->cart->add_to_cart( $upsell_product_id );
    643             }
     1925
     1926
     1927            }
     1928
     1929
    6441930            $redirection = get_post_meta($product_id, 'thp_upsellpopup_redirect', true);
    645            
     1931
     1932
     1933           
     1934
     1935
    6461936            if ( $redirection == '2cart' ) {
     1937
     1938
    6471939                $redirect_url = get_permalink( get_option( 'woocommerce_cart_page_id' ) );
    648             }
     1940
     1941
     1942            }
     1943
     1944
    6491945            elseif ( $redirection == '3checkout' ) {
     1946
     1947
    6501948                $redirect_url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) );
    651             }
    652         }
     1949
     1950
     1951            }
     1952
     1953
     1954        }
     1955
     1956
    6531957        else {
     1958
     1959
    6541960            $redirect_url = get_permalink( $upsell_product_id );
    655         }
    656     }
     1961
     1962
     1963        }
     1964
     1965
     1966    }
     1967
     1968
    6571969    elseif ($clicked == 'no') {
    658        
     1970
     1971
     1972       
     1973
     1974
    6591975        $redirection = get_post_meta($product_id, 'thp_upsellpopup_redirect_no', true);
    660        
     1976
     1977
     1978       
     1979
     1980
    6611981        if ( $redirection == '2cart' ) {
     1982
     1983
    6621984            $redirect_url = get_permalink( get_option( 'woocommerce_cart_page_id' ) );
    663         }
     1985
     1986
     1987        }
     1988
     1989
    6641990        elseif ( $redirection == '3checkout' ) {
     1991
     1992
    6651993            $redirect_url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) );
    666         }
    667     }
    668    
     1994
     1995
     1996        }
     1997
     1998
     1999    }
     2000
     2001
     2002   
     2003
     2004
    6692005    echo $redirect_url;
     2006
     2007
    6702008    die();
     2009
     2010
    6712011}
     2012
     2013
    6722014add_action('wp_ajax_nopriv_thp_popup_form_action_ajax', 'thp_popup_form_action_ajax');
     2015
     2016
    6732017add_action('wp_ajax_thp_popup_form_action_ajax', 'thp_popup_form_action_ajax');
    6742018
    6752019
     2020
     2021
     2022
     2023
     2024
     2025
    6762026function thp_popup_form_action_ajax_mult () {
    677    
     2027
     2028
     2029   
     2030
     2031
    6782032    $product_id = filter_input( INPUT_POST, 'prod_id', FILTER_SANITIZE_NUMBER_INT );
     2033
     2034
    6792035    parse_str( filter_input( INPUT_POST, 'up_pids', FILTER_SANITIZE_STRING ), $up_prod_ids );
    680    
     2036
     2037
     2038   
     2039
     2040
    6812041    foreach($up_prod_ids as $mult_upsell_id => $i){
     2042
     2043
    6822044        foreach($i as $n => $id){
     2045
     2046
    6832047            //WC()->cart->add_to_cart( $id );
     2048
     2049
    6842050            if(isset($_REQUEST['quality-'.$id.''])){
     2051
     2052
    6852053                WC()->cart->add_to_cart( $id,$_REQUEST['quality-'.$id.''] );
     2054
     2055
    6862056            }else{
     2057
     2058
    6872059                WC()->cart->add_to_cart( $id );
    688             }
    689         }
    690     }
    691    
     2060
     2061
     2062            }
     2063
     2064
     2065        }
     2066
     2067
     2068    }
     2069
     2070
     2071   
     2072
     2073
    6922074    $redirection = get_post_meta($product_id, 'thp_upsellpopup_redirect', true);
    693    
     2075
     2076
     2077   
     2078
     2079
    6942080    if ( $redirection == '2cart' ) {
     2081
     2082
    6952083        $redirect_url = get_permalink( get_option( 'woocommerce_cart_page_id' ) );
    696     }
     2084
     2085
     2086    }
     2087
     2088
    6972089    elseif ( $redirection == '3checkout' ) {
     2090
     2091
    6982092        $redirect_url = get_permalink( get_option( 'woocommerce_checkout_page_id' ) );
    699     }
    700    
     2093
     2094
     2095    }
     2096
     2097
     2098   
     2099
     2100
    7012101    echo $redirect_url;
     2102
     2103
    7022104    die();
     2105
     2106
    7032107}
     2108
     2109
    7042110add_action('wp_ajax_nopriv_thp_popup_form_action_ajax_mult', 'thp_popup_form_action_ajax_mult');
     2111
     2112
    7052113add_action('wp_ajax_thp_popup_form_action_ajax_mult', 'thp_popup_form_action_ajax_mult');
    7062114
    7072115
     2116
     2117
     2118
     2119
     2120
     2121
    7082122function thp_format_wc_price () {
    709    
     2123
     2124
     2125   
     2126
     2127
    7102128    $raw_total = filter_input( INPUT_GET, 'total', FILTER_SANITIZE_STRING );
    711    
     2129
     2130
     2131   
     2132
     2133
    7122134    $formatted_total = wc_price($raw_total);
    713    
     2135
     2136
     2137   
     2138
     2139
    7142140    echo $formatted_total;
     2141
     2142
    7152143    die();
     2144
     2145
    7162146}
     2147
     2148
    7172149add_action('wp_ajax_nopriv_thp_format_wc_price', 'thp_format_wc_price');
     2150
     2151
    7182152add_action('wp_ajax_thp_format_wc_price', 'thp_format_wc_price');
    7192153
    7202154
     2155
     2156
     2157
     2158
     2159
     2160
Note: See TracChangeset for help on using the changeset viewer.