Advertisement:

Author Topic: Remove Check with seller and Free - Solved by Teseo  (Read 17073 times)

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Remove Check with seller and Free - Solved by Teseo
« on: December 26, 2015, 11:36:40 am »
Hello. Is it possible to remove Check with seller and Free in item-post and item-edit?
I would like to make price field a required field and allow just insertion of numbers as price. If no number is filled in, do not allow the ad to be posted and show a message to fill it in.
« Last Edit: December 29, 2015, 10:48:33 pm by Adyyda »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Remove Check with seller and Free
« Reply #1 on: December 26, 2015, 01:07:40 pm »
Hi,

Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function cust_make_price_required() { ?>


    <script type="text/javascript">
        $inputPrice = $('input#price');
        if ($inputPrice.parent('div').css('display') != 'none') { $inputPrice.prop('required', true); }
        else { $inputPrice.prop('required', false); }
    </script>

<?php }

osc_add_hook('item_form''cust_make_price_required'6);
osc_add_hook('item_edit''cust_make_price_required'6);
?>


Regards

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: Remove Check with seller and Free
« Reply #2 on: December 27, 2015, 10:12:45 am »
Hello Teseo. Works with some issues.

If i do not fill in price field, it will not go further and will show a popup with "Please fill out this field" - how can i translate this and change the look to mimic the rest of error messages from the fields?
If i fill in 123, all is fine.
If i fill in csdcsd the ad will be saved and when activated, will see "Free" instead of "csdcsd".

This should not happen - price input must allow input of numbers only - eventually we can place a note bellow informing users to fill in just numbers.

The present implementation of price with 3 different results is not ok after me. A new user will never know how this works. Major websites like olx have 3 radio inputs that show clearly each option so that any user can make his selection fast and properly.


teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Remove Check with seller and Free
« Reply #3 on: December 28, 2015, 08:59:36 pm »
Hi again,

This has not been easy to build, but I guess is an important addition and I wanted to study this whole Javascript validation thing:

Add this at the very bottom of your theme functions.php:
Notes:
1.- Take care not to leave blank lines after this.
2.- If your theme functions.php doesn't end with ?> skip first line of my code.

Code: [Select]
<?php
function cust_price_validation_rules() { ?>


    <script type="text/javascript">
        var inputPrice = $('input#price');
        if (inputPrice.parent('div').css('display') != 'none') {
            inputPrice.rules("add", {
                required:true,
                number: true,
                min: 1,
                messages: {
                    required: '<?php echo osc_esc_js(__("Price: this field is required"osc_current_web_theme())); ?>.',
                    number: '<?php echo osc_esc_js(__("Price: Please enter a valid number"osc_current_web_theme())); ?>.',
                    min: '<?php echo osc_esc_js(__("Price: Please enter a value greater than 0"osc_current_web_theme())); ?>.'
                }
            });
        }
        else { inputPrice.rules("remove") }
    </script>

<?php }

osc_add_hook('item_form''cust_price_validation_rules'6);
osc_add_hook('item_edit''cust_price_validation_rules'6);
?>


Of course to get the error messages translated you need to add those three strings to your theme messages.po using Poedit.

Regards

Adyyda

  • Sr. Member
  • ****
  • Posts: 435
Re: Remove Check with seller and Free
« Reply #4 on: December 29, 2015, 10:48:12 pm »
Thanks

Rivaldo

  • Newbie
  • *
  • Posts: 3
Re: Remove Check with seller and Free - Solved by Teseo
« Reply #5 on: April 17, 2019, 05:30:06 pm »
Hello Teseo does this work on the veronika theme?

please explain more about where I have to set this code in the veronika theme to get rid of checks with the seller and it's free.