Plugin Directory

Changeset 2264115


Ignore:
Timestamp:
03/19/2020 07:43:06 PM (6 years ago)
Author:
transact
Message:

display donation as dollars and cents

Location:
transact
Files:
12 edited
1 copied

Legend:

Unmodified
Added
Removed
  • transact/tags/4.2.0/admin/controllers/transact-admin-settings-post.php

    r2262712 r2264115  
    132132            $price = sanitize_text_field( $_POST['transact_price'] );
    133133            // Update the meta field.
    134             update_post_meta( $post_id, 'transact_price', $price);
     134            update_post_meta( $post_id, 'transact_price', $price * 100);
    135135        }
    136136
     
    274274            function check_transact_price(event) {
    275275                console.log("check_transact_price", event);
    276                 let price = document.getElementById('transact_price').value;
     276                let price = document.getElementById('transact_price').value * 100;
    277277
    278278                if (price.length > 0 &&  Number.isInteger(parseInt(price))) {
    279279                    price = parseInt(price); // will set 0 if input is 0.1
    280280                    console.log('check_transact_price IS valid', price)
    281                     document.getElementById('transact_price').value = price.toString();
     281                    document.getElementById('transact_price').value = (price / 100).toString();
    282282                } else {
    283283                    alert('price is not valid');
     
    453453            </div>
    454454            <div class="transact_meta_field">
    455                 <input type="number" min="1" max="99999" id="transact_price"
    456                     onchange="check_transact_price()"
    457                     name="transact_price" value="<?php echo esc_attr( $value[1] ); ?>"  <?php echo esc_attr($price_disabled); ?> />
     455                <span class="transact-price-input">
     456                    <input type="number" min="0.01" step="0.01" id="transact_price" class="transact-price-input__field"
     457                        onchange="check_transact_price()"
     458                        name="transact_price" value="<?php echo esc_attr( $value[1] ) / 100; ?>"  <?php echo esc_attr($price_disabled); ?> />
     459                </span>
    458460                <span id="price_alert" style="color: red; display: none;"><?php esc_html_e('You need to set a price!', 'transact');?></span>
    459461            </div>
     
    483485    public function set_transact_style()
    484486    {
     487        wp_enqueue_style('transact', FRONTEND_ASSETS_URL . 'style.css');
    485488        wp_enqueue_style(
    486489            'transact-admin',
  • transact/tags/4.2.0/frontend/assets/style.css

    r2245834 r2264115  
    178178}
    179179
     180.transact-price-input {
     181  position: relative;
     182  display: block;
     183  font-size: 15px;
     184}
     185.transact-price-input::before {
     186  content: '$';
     187  position: absolute;
     188  top: 50%;
     189  left: 10px;
     190  line-height: 0;
     191  z-index: 10;
     192}
     193.transact-price-input input.transact-price-input__field {
     194  padding-left: 20px !important;
     195}
     196
    180197/* SQUARE BUTTON
    181198    background-color: #19a5ae;
  • transact/tags/4.2.0/frontend/assets/transact_post.js

    r2262712 r2264115  
    165165     */
    166166    function setDonateAmount() {
    167         var donate = jQuery('#donate_val').val();
    168         if (!donate) {
     167        var donate = jQuery('#donate_val').val() * 100;
     168        if (!donate || donate < 1) {
    169169            alert('Invalid Donation Amount');
    170170            return;
  • transact/tags/4.2.0/frontend/controllers/transact-handle-buttons.php

    r2262712 r2264115  
    9999        $price = get_post_meta($this->post_id, 'transact_price', true );
    100100        $button = $this->print_donate_button($this->options, $number_of_words);
    101         $input = '<input type="number" name="donate" class="transact-donate_amount" id="donate_val" onchange="TransactWP.setDonateAmount()" value="'.($price ? $price : 1).'"/>';
     101        $input = '<span class="transact-price-input"><input type="number" step="0.01" min="0.01" name="donate" class="transact-donate_amount transact-price-input__field" ' .
     102            'id="donate_val" onchange="TransactWP.setDonateAmount()" value="' .
     103            ($price ? ($price / 100) : 0.01) .
     104            '"/></span>';
    102105        return $input . $button;
    103106    }
  • transact/tags/4.2.0/readme.txt

    r2262712 r2264115  
    66Requires PHP: 5.6
    77Tested up to: 5.3.2
    8 Stable tag: 4.1.1
     8Stable tag: 4.2.0
    99License: APACHE-2.0
    1010License URI: https://www.apache.org/licenses/LICENSE-2.0
     
    8181== Changelog ==
    8282
     83= 4.2.0 =
     84* Display pricing as dollars and cents.
     85
    8386= 4.1.1 =
    8487* Fix for donation pages.
  • transact/tags/4.2.0/transact-plugin.php

    r2262712 r2264115  
    33 * Plugin Name: transact.io
    44 * Description: Integrates transact.io services into WP
    5  * Version: 4.1.1
     5 * Version: 4.2.0
    66 * Author: transact.io
    77 * Author URI: https://transact.io
  • transact/trunk/admin/controllers/transact-admin-settings-post.php

    r2262712 r2264115  
    132132            $price = sanitize_text_field( $_POST['transact_price'] );
    133133            // Update the meta field.
    134             update_post_meta( $post_id, 'transact_price', $price);
     134            update_post_meta( $post_id, 'transact_price', $price * 100);
    135135        }
    136136
     
    274274            function check_transact_price(event) {
    275275                console.log("check_transact_price", event);
    276                 let price = document.getElementById('transact_price').value;
     276                let price = document.getElementById('transact_price').value * 100;
    277277
    278278                if (price.length > 0 &&  Number.isInteger(parseInt(price))) {
    279279                    price = parseInt(price); // will set 0 if input is 0.1
    280280                    console.log('check_transact_price IS valid', price)
    281                     document.getElementById('transact_price').value = price.toString();
     281                    document.getElementById('transact_price').value = (price / 100).toString();
    282282                } else {
    283283                    alert('price is not valid');
     
    453453            </div>
    454454            <div class="transact_meta_field">
    455                 <input type="number" min="1" max="99999" id="transact_price"
    456                     onchange="check_transact_price()"
    457                     name="transact_price" value="<?php echo esc_attr( $value[1] ); ?>"  <?php echo esc_attr($price_disabled); ?> />
     455                <span class="transact-price-input">
     456                    <input type="number" min="0.01" step="0.01" id="transact_price" class="transact-price-input__field"
     457                        onchange="check_transact_price()"
     458                        name="transact_price" value="<?php echo esc_attr( $value[1] ) / 100; ?>"  <?php echo esc_attr($price_disabled); ?> />
     459                </span>
    458460                <span id="price_alert" style="color: red; display: none;"><?php esc_html_e('You need to set a price!', 'transact');?></span>
    459461            </div>
     
    483485    public function set_transact_style()
    484486    {
     487        wp_enqueue_style('transact', FRONTEND_ASSETS_URL . 'style.css');
    485488        wp_enqueue_style(
    486489            'transact-admin',
  • transact/trunk/frontend/assets/style.css

    r2245834 r2264115  
    178178}
    179179
     180.transact-price-input {
     181  position: relative;
     182  display: block;
     183  font-size: 15px;
     184}
     185.transact-price-input::before {
     186  content: '$';
     187  position: absolute;
     188  top: 50%;
     189  left: 10px;
     190  line-height: 0;
     191  z-index: 10;
     192}
     193.transact-price-input input.transact-price-input__field {
     194  padding-left: 20px !important;
     195}
     196
    180197/* SQUARE BUTTON
    181198    background-color: #19a5ae;
  • transact/trunk/frontend/assets/transact_post.js

    r2262712 r2264115  
    165165     */
    166166    function setDonateAmount() {
    167         var donate = jQuery('#donate_val').val();
    168         if (!donate) {
     167        var donate = jQuery('#donate_val').val() * 100;
     168        if (!donate || donate < 1) {
    169169            alert('Invalid Donation Amount');
    170170            return;
  • transact/trunk/frontend/controllers/transact-handle-buttons.php

    r2262712 r2264115  
    9999        $price = get_post_meta($this->post_id, 'transact_price', true );
    100100        $button = $this->print_donate_button($this->options, $number_of_words);
    101         $input = '<input type="number" name="donate" class="transact-donate_amount" id="donate_val" onchange="TransactWP.setDonateAmount()" value="'.($price ? $price : 1).'"/>';
     101        $input = '<span class="transact-price-input"><input type="number" step="0.01" min="0.01" name="donate" class="transact-donate_amount transact-price-input__field" ' .
     102            'id="donate_val" onchange="TransactWP.setDonateAmount()" value="' .
     103            ($price ? ($price / 100) : 0.01) .
     104            '"/></span>';
    102105        return $input . $button;
    103106    }
  • transact/trunk/readme.txt

    r2262712 r2264115  
    66Requires PHP: 5.6
    77Tested up to: 5.3.2
    8 Stable tag: 4.1.1
     8Stable tag: 4.2.0
    99License: APACHE-2.0
    1010License URI: https://www.apache.org/licenses/LICENSE-2.0
     
    8181== Changelog ==
    8282
     83= 4.2.0 =
     84* Display pricing as dollars and cents.
     85
    8386= 4.1.1 =
    8487* Fix for donation pages.
  • transact/trunk/transact-plugin.php

    r2262712 r2264115  
    33 * Plugin Name: transact.io
    44 * Description: Integrates transact.io services into WP
    5  * Version: 4.1.1
     5 * Version: 4.2.0
    66 * Author: transact.io
    77 * Author URI: https://transact.io
Note: See TracChangeset for help on using the changeset viewer.