Advertisement:

Author Topic: Developing the concept of donation when posting an ad - Hide price, etc.  (Read 1133 times)

tabuausada

  • Jr. Member
  • **
  • Posts: 77
Hi!
I'm trying to develop the concept of donation when posting an ad in bender theme but not shure what to do and how to do it.
I have a custom field with a drop down list: sell, buy, swap, rent, service, etc. and I woul like to ad the option donate. But in a donation I believe that it doesn't make sense to show a price for example so I would like to hide the price field when posting an ad (after choosing the option donate...) and when showing a donation ad the price field should also be hidden.
Anyone has a clue on how to hide a standard field whenever a certain custom field has a certain value? 
Thanks for all the help   

fog

  • Hero Member
  • *****
  • Posts: 1062
Re: Developing the concept of donation when posting an ad - Hide price, etc.
« Reply #1 on: October 01, 2015, 05:24:54 pm »
Hi,
For item-post.php maybe you need use javascript.
The div of field price need be hidden by default, and when user choose the different option of donate, the div of price field need be visible. For other hand when user choose the donate option on your dropdown menu, the price field need be hidden.

For item.php you need use a condition with the parameters: osc_item_meta_name(), and  osc_item_meta_value()
No need javascript with this, you need pass the parameter on the functions, the name and right value, maybe is needed.

The condition can be something like: if(osc_item_meta_value() != 'donation'){... price code ...}.
Maybe just the value maybe works, you need try the possibilities.

Or something like:  if(osc_item_meta_name('name-of-dropdown-menu') && !osc_item_meta_value('donation'){... price code ...}. Maybe works.


Maybe this can help you for item-post.php
You need to know the class name you use for field price and hide the div with css, firstly.
Find all ID of options, of your dropdown menu and change it on javascript (#id_option).
Use an inspector browser and you find it.

Code: [Select]
<script type="text/javascript">
$(document).ready(
    function() {
        $("#id_option_sell").click(function() {
            $(".price").show();
        });
        $("#id_option_buy").click(function() {
            $(".price").show();
        });
        $("#id_option_swap").click(function() {
            $(".price").show();
        });
        $("#id_option_rent").click(function() {
            $(".price").show();
        });
        $("#id_option_service").click(function() {
            $(".price").show();
        });
        $("#id_option_donation").click(function() {
            $(".price").hide();
        });       
    });
</script>

Or the function maybe can works like this, you need try

Code: [Select]
<script type="text/javascript">
$(document).ready(
    function() {
        $("#id_option_sell, #id_option_buy, #id_option_swap, #id_option_rent, #id_option_service").click(function() {
            $(".price").show();
        });
        $("#id_option_donation").click(function() {
            $(".price").hide();
        });       
    });
</script>

Regards
« Last Edit: October 01, 2015, 06:38:26 pm by fog »

tabuausada

  • Jr. Member
  • **
  • Posts: 77
Re: Developing the concept of donation when posting an ad - Hide price, etc.
« Reply #2 on: December 09, 2015, 03:10:24 am »
Fog, thanks a lot for your guidance (once again...)

This works for item.php (hide price field...)

Replace:

<?php if( osc_price_enabled_at_items() ) { ?><span class="price"><?php echo osc_item_formated_price(); ?></span> <?php } ?>            
       
With:


<?php
$getitemmeta=osc_get_item_meta();
$fieldvalue=$getitemmeta[2][s_value];      
if($fieldvalue <> 'Donation') { ?> 
<?php if( osc_price_enabled_at_items() ) { ?><span class="price"><?php echo osc_item_formated_price(); ?></span> <?php } ?>            
<?php } ?>

Number 2 is the key of the custom field in the database...

I will work now on item-post.php