Upgrade place selects free always as default

This topic contains 1 reply, has 2 voices, and was last updated by  Paolo 9 years, 2 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #32794

    P O
    Expired Member
    Post count: 501

    I created a free package to have some listings and a payed one so users can upgrade. I hided the free one with css so new users don’t see it and by default the payed one is selected.

    1- When a new user comes, he can create an account, add a listing and by default the payed one is selected. (the free one is hidden with css)

    2- When someone claims a place and they hit upgrade. The free is hidden, but its the default selected. So they have to click the payed one by hand.

    Why is the payed not selected by default when upgrading and how can I fix it ?

    Thanks.

    #32802

    Paolo
    Site Admin
    Post count: 31206

    Please add this to your theme functions.php

    
    
    remove_action('geodir_after_edit_post_link', 'geodir_display_post_upgrade_link', 1); 
    add_action('geodir_after_edit_post_link', 'my_geodir_display_post_upgrade_link', 1); 
    
    function my_geodir_display_post_upgrade_link(){
    	
    	global $post,$preview; 
    	
    	if(!$preview){
    	
    		if(is_user_logged_in() && $post->post_author == get_current_user_id()){
    								
    				$post_id = $post->ID;
    				$post_package_id = isset($post->package_id) ? $post->package_id : '';
    				if(isset($_REQUEST['pid']) && $_REQUEST['pid'] != ''){
    					$post_id = $_REQUEST['pid'];
    					
    					if(empty($post_package_id))
    						$post_package_id = geodir_get_post_meta($post_id,'package_id',true);
    				}
    				
    				$postlink = get_permalink( get_option('geodir_add_listing_page') );
    				$editlink = geodir_getlink($postlink,array('pid'=>$post_id),false);
    				
    				
    				$post_status = get_post_status( $post_id );
    				
    				// show renew link before pre expiry days * 2
    				$post_expire_date = isset($post->expire_date) ? $post->expire_date : '';
    				$preexpiry_notice = false;
    				if (get_option('geodir_listing_preexpiry_notice_disable') && get_option('geodir_listing_preexpiry_notice_days')!='' && $post_expire_date != '0000-00-00' && $post_expire_date != '' && strtolower($post_expire_date) != 'never' && strtotime($post_expire_date) > strtotime(date('01-01-1970')))  {
    					$preexpiry_date = strtotime($post_expire_date) - (DAY_IN_SECONDS * get_option('geodir_listing_preexpiry_notice_days') * 2);
    					$preexpiry_notice = $preexpiry_date <= strtotime(date('Y-m-d')) ? true : false;
    				}
    				
    				$action_link = __('Upgrade Listing', GEODIRPAYMENT_TEXTDOMAIN);
    				if($post_status == 'draft' || $preexpiry_notice){
    					$action_link = __('Renew Listing', GEODIRPAYMENT_TEXTDOMAIN);
    				}
    		
    				$upgradelink = geodir_getlink($editlink,array('package_id'=>'ADD_YOUR_ID_HERE'),false);  
    				
    				echo '<p class="geodir_upgrade_link"><i class="fa fa-chevron-circle-up"></i> <a href="'.$upgradelink.'">'.$action_link.'</a></p>';
    		}
    		
    	}
    
    	
    }

    Change where it says ADD_YOUR_ID_HERE with the price package ID needed for the upgrade.

    I’ve tested it in our demo and works, however if you have more than one CPT this will not work and will have to be extended with a little extra conditional function.

    Let us know,

Viewing 2 posts - 1 through 2 (of 2 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket