• Resolved 368durham

    (@368durham)


    Hi Greg,

    Do you think it would be possible to include the ability to mark an existing advert as featured? For example, if a non-featured advert was already posted, the user would be able to go to manage my ads, or edit my ads and mark the item as featured (potentially with the ability to pay for the one-time featured marking.)

    See example screenshot:

    View post on imgur.com

    What are your thoughts?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    i am afraid i am not really planning adding a feature, but you can add something similar by adding the code below in your theme functions.php file

    
    add_action( "adverts_sh_manage_actions_left", function( $post_id, $baseurl ) {
        ?>
        <form id="mark-as-featured" action="<?php echo esc_attr($baseurl) ?>" method="post" style="display:inline-block">
        <input type="hidden" name="advert_renew" value="<?php echo esc_attr( $post_id ) ?>" />
        <input type="hidden" name="payments_listing_type" value="123" />
        <a href="#" onclick="document.getElementById('mark-as-featured').submit();" class="adverts-manage-action">
            <span class="adverts-icon-flash"></span>
            Feature Ad $5.00
        </a>
        </form> 
        <?php
    }, 10, 2 );
    

    The code will show a new button in [adverts_manage] next to each Advert. Clicking the link will take you to the Ad renew page. So technically this is just a shortcut to selected renewal pricing, if user will purchase it his Ad will become featured but also the publication and expiration dates will updated.

    The only thing you need to change in the code is the “123” which you should replace with actual ID of the renewal pricing which will feature the Ad.

    I suppose this is not exactly what you are looking for but it is the best solution i can offer without a lot of programming.

    Thread Starter 368durham

    (@368durham)

    Hey Greg,

    That’s actually pretty great! This will work.

    Thanks again.

    Thread Starter 368durham

    (@368durham)

    Hey Greg,

    Ran into a slight issue with this. The new link shows up in the manage my ads section but when clicking it on, it just says “Ad renewed. Go back to Ads list.” and doesn’t show the price.

    I changed the 123 to the Woocommerce product I had selected with no luck. I also made sure to check if the product was set as a listing or renewal (tried both with no luck)

    I even tried disabling the Woocommerce and using the default built in pricing with no luck. Any suggestions?

    Plugin Author Greg Winiarski

    (@gwin)

    To make this code work with WC integration you need an additional hidden input, the complete code would be

    
    add_action( "adverts_sh_manage_actions_left", function( $post_id, $baseurl ) {
        ?>
        <form id="mark-as-featured" action="<?php echo esc_attr($baseurl) ?>" method="post" style="display:inline-block">
        <input type="hidden" name="_adverts_renew" id="_adverts_renew" value="1" />    
        <input type="hidden" name="advert_renew" value="<?php echo esc_attr( $post_id ) ?>" />
        <input type="hidden" name="payments_listing_type" value="409" />
        <a href="#" onclick="document.getElementById('mark-as-featured').submit();" class="adverts-manage-action">
            <span class="adverts-icon-flash"></span>
            Feature Ad $5.00
        </a>
        </form> 
        <?php
    }, 10, 2 );
    

    If after clicking the “Feature Ad $5.00” button you see “Ad renewed. Go back to Ads list.” message then it means that in field payments_listing_type you have entered an ID of a renewal product which costs $0.00.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Ability to Mark Existing Ad as Featured’ is closed to new replies.