├── src ├── payment-method │ ├── style.scss │ └── index.js ├── fonts │ ├── woowallet.eot │ ├── woowallet.ttf │ ├── woowallet.woff │ └── woowallet.svg ├── admin │ ├── product.js │ ├── actions.js │ ├── main.js │ ├── export.js │ └── order.js ├── partial-payment │ ├── style.scss │ └── index.js ├── scss │ ├── export.scss │ └── admin.scss └── frontend │ └── main.js ├── .gitignore ├── assets ├── images │ ├── wallet-coupons.png │ ├── wallet-importer.png │ ├── wallet-withdrawal.png │ └── wallet-affiliatewp.png └── jquery │ └── css │ ├── images │ ├── ui-icons_444444_256x240.png │ ├── ui-icons_555555_256x240.png │ ├── ui-icons_777620_256x240.png │ ├── ui-icons_777777_256x240.png │ ├── ui-icons_cc0000_256x240.png │ └── ui-icons_ffffff_256x240.png │ └── responsive.dataTables.min.css ├── postcss.config.js ├── templates ├── no-access.php ├── transactions.php ├── mini-wallet.php ├── topup.php ├── emails │ ├── plain │ │ ├── user-new-transaction.php │ │ └── low-wallet-balance.php │ ├── low-wallet-balance.php │ └── user-new-transaction.php ├── transfer.php ├── admin │ ├── edit-balance.php │ └── html-exporter.php ├── woo-wallet-partial-payment.php ├── referrals.php └── wc-endpoint-wallet.php ├── composer.json ├── includes ├── class-woo-wallet-helper.php ├── marketplace │ ├── wc-merketplace │ │ ├── class-woo-wallet-wcmp.php │ │ └── class-woo-wallet-wcmp-gateway.php │ └── wcfmmp │ │ ├── class-woo-wallet-wcfmmp-gateway.php │ │ └── class-woo-wallet-wcfmmp.php ├── class-woo-wallet-api.php ├── class-woo-wallet-dependencies.php ├── actions │ ├── class-woo-wallet-action-new-registration.php │ ├── class-woo-wallet-action-daily-visits.php │ └── class-woo-wallet-action-product-review.php ├── abstracts │ └── abstract-woo-wallet-actions.php ├── class-woo-wallet-payments-blocks.php ├── class-woo-wallet-actions.php ├── class-woo-wallet-widgets.php ├── helper │ └── woo-wallet-update-functions.php ├── class-woo-wallet-partial-payment-blocks.php ├── emails │ ├── class-woo-wallet-email-low-wallet-balance.php │ └── class-woo-wallet-email-new-transaction.php ├── api │ ├── class-woo-wallet-rest-controller.php │ ├── class-wc-rest-woo-wallet-controller.php │ └── Controllers │ │ └── Version3 │ │ └── class-wc-rest-wallet-controller.php ├── admin │ └── class-woo-wallet-transaction-details.php ├── multicurrency │ ├── woocommerce-currency-switcher │ │ └── class-wallet-multi-currency.php │ └── woocommerce-multilingual │ │ └── class-wallet-wpml-multi-currency.php ├── class-woo-wallet-install.php └── class-woo-wallet-payment-method.php ├── README.md ├── uninstall.php ├── woo-wallet.php ├── package.json └── webpack.config.js /src/payment-method/style.scss: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/fonts/woowallet.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/src/fonts/woowallet.eot -------------------------------------------------------------------------------- /src/fonts/woowallet.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/src/fonts/woowallet.ttf -------------------------------------------------------------------------------- /src/fonts/woowallet.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/src/fonts/woowallet.woff -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Grunt 2 | /node_modules/ 3 | none 4 | package-lock.json 5 | 6 | # Sass 7 | .sass-cache/ 8 | /build/ -------------------------------------------------------------------------------- /assets/images/wallet-coupons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/images/wallet-coupons.png -------------------------------------------------------------------------------- /assets/images/wallet-importer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/images/wallet-importer.png -------------------------------------------------------------------------------- /assets/images/wallet-withdrawal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/images/wallet-withdrawal.png -------------------------------------------------------------------------------- /assets/images/wallet-affiliatewp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/images/wallet-affiliatewp.png -------------------------------------------------------------------------------- /assets/jquery/css/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/jquery/css/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /assets/jquery/css/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/jquery/css/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /assets/jquery/css/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/jquery/css/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /assets/jquery/css/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/jquery/css/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /assets/jquery/css/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/jquery/css/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /assets/jquery/css/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/malsubrata/woo-wallet/HEAD/assets/jquery/css/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | // This file is used to configure PostCSS for the Woo Wallet plugin. 2 | // It is used to process CSS files with Tailwind CSS and Autoprefixer. 3 | module.exports = { 4 | plugins: [ 5 | '@tailwindcss/postcss', 6 | 'autoprefixer' 7 | ] 8 | }; 9 | -------------------------------------------------------------------------------- /src/admin/product.js: -------------------------------------------------------------------------------- 1 | /* global woo_wallet_admin_product_param */ 2 | 3 | jQuery(document).ready(function ($) { 4 | if (woo_wallet_admin_product_param.is_hidden) { 5 | $('tr.post-' + woo_wallet_admin_product_param.product_id + '.type-product').remove(); 6 | } 7 | }); -------------------------------------------------------------------------------- /src/admin/actions.js: -------------------------------------------------------------------------------- 1 | jQuery(function ($) { 2 | $('#woo_wallet_referrals_referring_visitors_limit_duration').on('change', function(){ 3 | if('0' === $(this).val()){ 4 | $('#woo_wallet_referrals_referring_visitors_limit').closest('tr').hide(); 5 | } else{ 6 | $('#woo_wallet_referrals_referring_visitors_limit').closest('tr').show(); 7 | } 8 | }).change(); 9 | $('#woo_wallet_referrals_referring_signups_limit_duration').on('change', function(){ 10 | if('0' === $(this).val()){ 11 | $('#woo_wallet_referrals_referring_signups_limit').closest('tr').hide(); 12 | } else{ 13 | $('#woo_wallet_referrals_referring_signups_limit').closest('tr').show(); 14 | } 15 | }).change(); 16 | }); -------------------------------------------------------------------------------- /src/partial-payment/style.scss: -------------------------------------------------------------------------------- 1 | .wc-block-components-partial-payment { 2 | flex-direction: column; 3 | position: relative; 4 | 5 | .wc-block-components-partial-payment_form { 6 | display: flex; 7 | margin-bottom: 0; 8 | width: 100%; 9 | 10 | .wc-block-components-partial-payment_input { 11 | flex-grow: 1; 12 | margin-bottom: 0; 13 | margin-top: 0; 14 | } 15 | 16 | .wc-block-components-partial-payment_button { 17 | flex-shrink: 0; 18 | height: 3em; 19 | margin-left: 8px; 20 | padding-left: 24px; 21 | padding-right: 24px; 22 | white-space: nowrap; 23 | } 24 | } 25 | } 26 | 27 | .slot-wrapper:has(.wc-block-components-discounts-meta) { 28 | padding: 16px 0 !important; 29 | } -------------------------------------------------------------------------------- /templates/no-access.php: -------------------------------------------------------------------------------- 1 | 23 |
24 | 25 |
26 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "malsubrata/woo-wallet", 3 | "type": "wordpress-plugin", 4 | "license": "GPL-3.0-or-later", 5 | "description": "A powerful, extendable WooCommerce wallet system which support payment, partial payment, cashback reward program as well as refund for your WooCommerce store.", 6 | "homepage": "https://standalonetech.com/", 7 | "authors": [ 8 | { 9 | "name": "Subrata Mal", 10 | "email": "m.subrata1991@gmail.com", 11 | "homepage": "https://github.com/malsubrata" 12 | } 13 | ], 14 | "keywords": [ 15 | "wordpress", 16 | "woocommerce-wallet", 17 | "wallet", 18 | "wordpress-plugin" 19 | ], 20 | "support": { 21 | "issues": "https://github.com/malsubrata/woo-wallet/issues" 22 | }, 23 | "require": { 24 | "php": ">=5.6", 25 | "composer/installers": "~1.6" 26 | } 27 | } -------------------------------------------------------------------------------- /includes/class-woo-wallet-helper.php: -------------------------------------------------------------------------------- 1 | update_meta_data( $key, $value ); 30 | } 31 | if ( is_callable( array( $order, 'save' ) ) && $do_save ) { 32 | $order->save(); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [TeraWallet](https://standalonetech.com/) [](https://plugintests.com/plugins/woo-wallet/latest) [](https://plugintests.com/plugins/woo-wallet/latest) 2 | 3 | Welcome to the WooCommerce Wallet repository on GitHub. Here you can browse the source, look at open issues and keep track of development. 4 | 5 | If you are not a developer, please use the [WooCommerce Wallet plugin page](https://wordpress.org/plugins/woo-wallet/) on WordPress.org. 6 | 7 | ## Support 8 | This repository is not suitable for support. Please don't use our issue tracker for support requests, but for core issues only. Support can take place through the appropriate channels: 9 | 10 | * The [TeraWallet premium support portal](https://standalonetech.com/support-forums/) for customers who have purchased extensions. 11 | * [Our community forum on wp.org](https://wordpress.org/support/plugin/woo-wallet) which is available for all WordPress users. 12 | -------------------------------------------------------------------------------- /templates/transactions.php: -------------------------------------------------------------------------------- 1 | 22 | 23 |31 | 35 |
36 |37 | 38 | wallet->get_wallet_balance( $user->ID ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 41 | ?> 42 | 43 |
44 |45 | 46 |
47 | wallet->get_wallet_balance( $user->ID, 'edit' ); 23 | echo '= ' . esc_html( $email_heading ) . " =\n\n"; 24 | echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; 25 | /* translators: 1: wallet amount */ 26 | echo sprintf( esc_html__( 'Your %s wallet balance is low.', 'woo-wallet' ), wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 27 | echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; 28 | /* translators: 1: wallet amount */ 29 | echo sprintf( esc_html__( 'Current Balance: %s', 'woo-wallet' ), $currency . ' ' . woo_wallet()->wallet->get_wallet_balance( $user->ID, 'edit' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 30 | echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; 31 | echo sprintf( esc_html__( 'Please recharge you wallet now to avoid any disruption.', 'woo-wallet' ) ); 32 | 33 | echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n"; 34 | echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 35 | -------------------------------------------------------------------------------- /templates/emails/user-new-transaction.php: -------------------------------------------------------------------------------- 1 | 29 | 30 |ID ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> wallet->get_wallet_balance( $user->ID ); ?>
31 | 32 | 33 |ID ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> wallet->get_wallet_balance( $user->ID ); ?>
34 | 35 | { 24 | return decodeEntities( settings.description || '' ); 25 | }; 26 | 27 | const formatedBalance = () => { 28 | const { balance, currency_symbol, decimal_separator, thousand_separator, decimals } = settings; 29 | // Ensure that 'amount' is a valid number 30 | let numericAmount = parseFloat(balance); 31 | if (isNaN(numericAmount)) { 32 | return amount; // Return the original value if it's not a valid number 33 | } 34 | // Format the amount to the required number of decimal places 35 | let fixedAmount = numericAmount.toFixed(decimals); 36 | // Split the integer and decimal parts 37 | let parts = fixedAmount.split('.'); 38 | // Add thousand separator to the integer part only 39 | parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousand_separator); 40 | // Rejoin integer and decimal parts with the correct decimal separator 41 | let formattedAmount = parts.join(decimal_separator); 42 | return decodeEntities(`${currency_symbol}${formattedAmount}`); 43 | } 44 | 45 | const CurrentBalance = () => { 46 | return ( 47 | 48 | { /* translators: 1: Wallet amount */ sprintf(__('| Current Balance: %s', 'woo-wallet'), formatedBalance())} 49 | 50 | ); 51 | } 52 | /** 53 | * Label component 54 | * 55 | * @param {*} props Props from payment API. 56 | */ 57 | const Label = ( props ) => { 58 | const { PaymentMethodLabel } = props.components; 59 | return <>| 50 | | 51 | | 52 | |
|---|---|---|
| 57 | | 58 | | 59 | |
{site_title}' ),
142 | 'placeholder' => $this->get_default_subject(),
143 | 'default' => '',
144 | ),
145 | 'heading' => array(
146 | 'title' => __( 'Email heading', 'woo-wallet' ),
147 | 'type' => 'text',
148 | 'desc_tip' => true,
149 | /* translators: %s: list of placeholders */
150 | 'description' => sprintf( __( 'Available placeholders: %s', 'woo-wallet' ), '{site_title}' ),
151 | 'placeholder' => $this->get_default_heading(),
152 | 'default' => '',
153 | ),
154 | 'email_type' => array(
155 | 'title' => __( 'Email type', 'woo-wallet' ),
156 | 'type' => 'select',
157 | 'description' => __( 'Choose which format of email to send.', 'woo-wallet' ),
158 | 'default' => 'html',
159 | 'class' => 'email_type wc-enhanced-select',
160 | 'options' => $this->get_email_type_options(),
161 | 'desc_tip' => true,
162 | ),
163 | );
164 | }
165 |
166 | }
167 |
168 | }
169 |
170 | return new Woo_Wallet_Email_Low_Wallet_Balance();
171 |
--------------------------------------------------------------------------------
/includes/api/class-woo-wallet-rest-controller.php:
--------------------------------------------------------------------------------
1 | namespace,
45 | '/' . $this->rest_base . '/(?P{site_title}, {transaction_date}' ),
151 | 'placeholder' => $this->get_default_subject(),
152 | 'default' => '',
153 | ),
154 | 'heading' => array(
155 | 'title' => __( 'Email heading', 'woo-wallet' ),
156 | 'type' => 'text',
157 | 'desc_tip' => true,
158 | /* translators: %s: list of placeholders */
159 | 'description' => sprintf( __( 'Available placeholders: %s', 'woo-wallet' ), '{site_title}, {transaction_date}' ),
160 | 'placeholder' => $this->get_default_heading(),
161 | 'default' => '',
162 | ),
163 | 'email_type' => array(
164 | 'title' => __( 'Email type', 'woo-wallet' ),
165 | 'type' => 'select',
166 | 'description' => __( 'Choose which format of email to send.', 'woo-wallet' ),
167 | 'default' => 'html',
168 | 'class' => 'email_type wc-enhanced-select',
169 | 'options' => $this->get_email_type_options(),
170 | 'desc_tip' => true,
171 | ),
172 | );
173 | }
174 |
175 | }
176 |
177 | }
178 |
179 | return new Woo_Wallet_Email_New_Transaction();
180 |
--------------------------------------------------------------------------------
/src/admin/export.js:
--------------------------------------------------------------------------------
1 | /* global ajaxurl, terawallet_export_params */
2 | import '../scss/export.scss';
3 | (function ($, window) {
4 | /**
5 | * teraWalletExportForm handles the export process.
6 | */
7 | var teraWalletExportForm = function ($form) {
8 | this.$form = $form;
9 | this.xhr = false;
10 | // Initial state.
11 | this.$form.find('.terawallet-exporter-progress').val(0);
12 |
13 | // Methods.
14 | this.processStep = this.processStep.bind(this);
15 |
16 | // Events.
17 | $form.on('submit', {teraWalletExportForm: this}, this.onSubmit);
18 |
19 | this.$form.find('.terawallet-exporter-type').on('change', {teraWalletExportForm: this}, this.onChangeType).change();
20 | };
21 |
22 | /**
23 | * Handle export form submission.
24 | */
25 | teraWalletExportForm.prototype.onSubmit = function (event) {
26 | event.preventDefault();
27 |
28 | var currentDate = new Date(),
29 | day = currentDate.getDate(),
30 | month = currentDate.getMonth() + 1,
31 | year = currentDate.getFullYear(),
32 | timestamp = currentDate.getTime(),
33 | filename = 'terawallet-transaction-export-' + day + '-' + month + '-' + year + '-' + timestamp + '.csv';
34 |
35 | event.data.teraWalletExportForm.$form.addClass('terawallet-exporter__exporting');
36 | event.data.teraWalletExportForm.$form.find('.terawallet-exporter-progress').val(0);
37 | event.data.teraWalletExportForm.$form.find('.terawallet-exporter-button').prop('disabled', true);
38 | event.data.teraWalletExportForm.processStep(1, $(this).serialize(), '', filename);
39 | };
40 |
41 | teraWalletExportForm.prototype.onChangeType = function(){
42 | if ($(this).is(':checked')) {
43 | $('.export-transaction-settings-fields').hide();
44 | } else{
45 | $('.export-transaction-settings-fields').show();
46 | }
47 | };
48 |
49 | /**
50 | * Process the current export step.
51 | */
52 | teraWalletExportForm.prototype.processStep = function (step, data, columns, filename) {
53 | var $this = this,
54 | export_type = $('.terawallet-exporter-type').is(':checked') ? 'balance' : 'transactions',
55 | selected_columns = $('.terawallet-exporter-columns').val(),
56 | selected_users = $('.terawallet-exporter-users').val(),
57 | from_date = $('.terawallet-exporter-from-date').val(),
58 | to_date = $('.terawallet-exporter-to-date').val();
59 | $.ajax({
60 | type: 'POST',
61 | url: ajaxurl,
62 | data: {
63 | form: data,
64 | action: 'terawallet_do_ajax_transaction_export',
65 | step: step,
66 | export_type: export_type,
67 | columns: columns,
68 | selected_columns: selected_columns,
69 | selected_users: selected_users,
70 | start_date: from_date,
71 | end_date: to_date,
72 | filename: filename,
73 | security: terawallet_export_params.export_nonce
74 | },
75 | dataType: 'json',
76 | success: function (response) {
77 | if (response.success) {
78 | if ('done' === response.data.step) {
79 | $this.$form.find('.terawallet-exporter-progress').val(response.data.percentage);
80 | window.location = response.data.url;
81 | setTimeout(function () {
82 | $this.$form.removeClass('terawallet-exporter__exporting');
83 | $this.$form.find('.terawallet-exporter-button').prop('disabled', false);
84 | }, 200);
85 | } else {
86 | $this.$form.find('.terawallet-exporter-progress').val(response.data.percentage);
87 | $this.processStep(parseInt(response.data.step, 10), data, response.data.columns, filename);
88 | }
89 | }
90 |
91 |
92 | }
93 | }).fail(function (response) {
94 | window.console.log(response);
95 | });
96 | };
97 |
98 | /**
99 | * Function to call teraWalletExportForm on jquery selector.
100 | */
101 | $.fn.terawallet_export_form = function () {
102 | new teraWalletExportForm(this);
103 | return this;
104 | };
105 |
106 | $('.terawallet-exporter').terawallet_export_form();
107 |
108 | $('.terawallet-exporter-users').selectWoo({
109 | language: {
110 | inputTooShort: function () {
111 | return terawallet_export_params.i18n.inputTooShort;
112 | },
113 | noResults: function () {
114 | return terawallet_export_params.i18n.no_resualt;
115 | },
116 | searching: function () {
117 | return terawallet_export_params.i18n.searching;
118 | }
119 | },
120 | minimumInputLength: 3,
121 | ajax: {
122 | url: ajaxurl,
123 | dataType: 'json',
124 | type: 'POST',
125 | delay: 250,
126 | data: function (term) {
127 | return {
128 | action: 'terawallet_export_user_search',
129 | security: terawallet_export_params.search_user_nonce,
130 | autocomplete_field: 'ID',
131 | term: term.term
132 | };
133 | },
134 | processResults: function (data) {
135 | // Tranforms the top-level key of the response object from 'items' to 'results'
136 | return {
137 | results: $.map(data, function (item) {
138 | return {
139 | id: item.value,
140 | text: item.label
141 | };
142 | })
143 | };
144 | }
145 | }
146 | });
147 |
148 | })(jQuery, window);
--------------------------------------------------------------------------------
/includes/admin/class-woo-wallet-transaction-details.php:
--------------------------------------------------------------------------------
1 | 'transaction',
30 | 'plural' => 'transactions',
31 | 'ajax' => false,
32 | 'screen' => 'wc-wallet-transactions',
33 | )
34 | );
35 | }
36 | /**
37 | * Get all columns.
38 | */
39 | public function get_columns() {
40 | return apply_filters(
41 | 'manage_woo_wallet_transactions_columns',
42 | array(
43 | 'name' => __( 'Name', 'woo-wallet' ),
44 | 'type' => __( 'Type', 'woo-wallet' ),
45 | 'amount' => __( 'Amount', 'woo-wallet' ),
46 | 'details' => __( 'Details', 'woo-wallet' ),
47 | 'created_by' => __( 'Created By', 'woo-wallet' ),
48 | 'date' => __( 'Date', 'woo-wallet' ),
49 | 'transaction_id' => __( 'ID', 'woo-wallet' ),
50 | )
51 | );
52 | }
53 |
54 | /**
55 | * Prepare the items for the table to process
56 | */
57 | public function prepare_items() {
58 | $columns = $this->get_columns();
59 | $hidden = $this->get_hidden_columns();
60 | $sortable = $this->get_sortable_columns();
61 |
62 | $per_page = $this->get_items_per_page( 'transactions_per_page', 10 );
63 | $current_page = $this->get_pagenum();
64 |
65 | $data = $this->table_data( ( $current_page - 1 ) * $per_page, $per_page );
66 | $this->_column_headers = array( $columns, $hidden, $sortable );
67 | $this->items = $data;
68 |
69 | $this->set_pagination_args(
70 | array(
71 | 'total_items' => $this->total_count,
72 | 'per_page' => $per_page,
73 | )
74 | );
75 | }
76 |
77 | /**
78 | * Output 'no users' message.
79 | *
80 | * @since 3.1.0
81 | */
82 | public function no_items() {
83 | esc_html_e( 'No transactions found.', 'woo-wallet' );
84 | }
85 |
86 | /**
87 | * Define which columns are hidden
88 | *
89 | * @return Array
90 | */
91 | public function get_hidden_columns() {
92 | return array( 'transaction_id' );
93 | }
94 |
95 | /**
96 | * Define the sortable columns
97 | *
98 | * @return Array
99 | */
100 | public function get_sortable_columns() {
101 | return array();
102 | }
103 |
104 | /**
105 | * Get the table data
106 | *
107 | * @param int $lower lower.
108 | * @param int $uper uper.
109 | * @return Array
110 | */
111 | private function table_data( $lower = 0, $uper = 10 ) {
112 | global $wpdb;
113 | $data = array();
114 | $user_id = filter_input( INPUT_GET, 'user_id' );
115 | if ( null === $user_id ) {
116 | return $data;
117 | }
118 | $transactions = get_wallet_transactions(
119 | array(
120 | 'user_id' => $user_id,
121 | 'limit' => $lower . ',' . $uper,
122 | )
123 | );
124 | $this->total_count = (int) $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM {$wpdb->base_prefix}woo_wallet_transactions WHERE user_id=%d", $user_id ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
125 | if ( ! empty( $transactions ) && is_array( $transactions ) ) {
126 | foreach ( $transactions as $key => $transaction ) {
127 | $data[] = array(
128 | 'transaction_id' => $transaction->transaction_id,
129 | 'name' => get_user_by( 'ID', $transaction->user_id )->display_name,
130 | 'type' => ( 'credit' === $transaction->type ) ? __( 'Credit', 'woo-wallet' ) : __( 'Debit', 'woo-wallet' ),
131 | 'amount' => wc_price( apply_filters( 'woo_wallet_amount', $transaction->amount, $transaction->currency, $transaction->user_id ), woo_wallet_wc_price_args( $transaction->user_id, array( 'currency' => $transaction->currency ) ) ),
132 | 'details' => $transaction->details,
133 | 'created_by' => $transaction->created_by,
134 | 'date' => wc_string_to_datetime( $transaction->date )->date_i18n( wc_date_format() ),
135 | );
136 | }
137 | }
138 | return $data;
139 | }
140 |
141 | /**
142 | * Define what data to show on each column of the table
143 | *
144 | * @param Array $item Data.
145 | * @param String $column_name - Current column name.
146 | *
147 | * @return Mixed
148 | */
149 | public function column_default( $item, $column_name ) {
150 | switch ( $column_name ) {
151 | case 'transaction_id':
152 | case 'name':
153 | case 'type':
154 | case 'date':
155 | return esc_html( $item[ $column_name ] );
156 | default:
157 | return apply_filters( 'woo_wallet_transaction_details_column_default', print_r( $item, true ), $column_name, $item ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r
158 | }
159 | }
160 | /**
161 | * Render amount column.
162 | *
163 | * @param array $item item.
164 | * @return void
165 | */
166 | protected function column_amount( $item ): void {
167 | echo $item['amount'] ? wp_kses_post( $item['amount'] ) : '–';
168 | }
169 |
170 | /**
171 | * Render details column.
172 | *
173 | * @param array $item item.
174 | * @return void
175 | */
176 | protected function column_details( $item ): void {
177 | echo $item['details'] ? wp_kses_post( $item['details'] ) : '–';
178 | }
179 |
180 | /**
181 | * Render created_by column.
182 | *
183 | * @param array $item item.
184 | * @return void
185 | */
186 | protected function column_created_by( $item ): void {
187 | if ( $item['created_by'] ) {
188 | echo '' . esc_html( get_user_by( 'ID', $item['created_by'] )->display_name ) . '';
189 | } else {
190 | echo '-';
191 | }
192 | }
193 | }
194 |
--------------------------------------------------------------------------------
/includes/api/class-wc-rest-woo-wallet-controller.php:
--------------------------------------------------------------------------------
1 | namespace,
44 | '/' . $this->rest_base . '/(?Pwallet->get_wallet_balance( get_current_user_id() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
93 || 143 | | 144 | | 145 | |
|---|---|---|
| date )->date_i18n( wc_date_format() ) ); ?> | 151 |details ); ?> | 152 |153 | type ? '+' : '-'; 155 | echo wp_kses_post( wc_price( apply_filters( 'woo_wallet_amount', $transaction->amount, $transaction->currency, $transaction->user_id ), woo_wallet_wc_price_args( $transaction->user_id ) ) ); 156 | ?> 157 | | 158 |