Forum Replies Created

Viewing 15 replies - 16 through 30 (of 48 total)
  • Thread Starter stevebower

    (@stevebower)

    Great, thanks.
    Top plugin, BTW!

    Hmm my url script was ‘run’ rather than showing the code. Trying this:

    
    // Upload the Data Sheet & add the url to a Custom Field (data_sheet)
    
    		function data_sheet_upload($post_id, $att_id, $file) {
    			$attachment_url = wp_get_attachment_url($att_id);
    			update_post_meta($post_id, "data_sheet", $attachment_url);
    		}
    
    		add_action('pmxi_attachment_uploaded', 'data_sheet_upload', 10, 3);
    
    	// Add a new tab for Data Sheets:
    
    		add_filter( 'woocommerce_product_tabs', 'data_sheet_tab' );
    		function data_sheet_tab( $tabs ) {
    			// Add the new tab
    			$tabs['data_sheet_tab'] = array(
    				'title'       => __( 'Data Sheet', 'text-domain' ),
    				'priority'    => 30,
    				'callback'    => 'data_sheet_tab_content'
    			);
    			return $tabs;
    		}
    		 
    	// The new data_sheet_tab_content
    		function data_sheet_tab_content() {
    		
    		echo '<h2>Data Sheet</h2>';
    		
    	//  Left this in for info as its the clever bit that gets the datasheet url from the data_sheet custom field:
    	//	echo get_post_meta( get_the_ID(), 'data_sheet', true );
    	//
    		
    	// Puts the url on the tab, or, if empty, a message
    		
    		if( get_post_meta( get_the_ID(), 'data_sheet', true ) )
    
    		{ echo '<strong><a href="' . get_post_meta( get_the_ID(), 'data_sheet', true ) . '" target="_blank"><img style="float: left; margin-right:15px;" src="https://demo.intersafety.co.uk/wp-content/uploads/pdf.png" height="35px" width="35px">Datasheet</a></strong>';
    		}
    		else
    		{
    			echo 'No data sheet available';
    		}
    
    		}
    //ends
    

    Hmm my url script was ‘run’ rather than showing the code. Trying this

    
    // Upload the Data Sheet & add the url to a Custom Field (data_sheet)
    
    		function data_sheet_upload($post_id, $att_id, $file) {
    			$attachment_url = wp_get_attachment_url($att_id);
    			update_post_meta($post_id, "data_sheet", $attachment_url);
    		}
    
    		add_action('pmxi_attachment_uploaded', 'data_sheet_upload', 10, 3);
    
    	// Add a new tab for Data Sheets:
    
    		add_filter( 'woocommerce_product_tabs', 'data_sheet_tab' );
    		function data_sheet_tab( $tabs ) {
    			// Add the new tab
    			$tabs['data_sheet_tab'] = array(
    				'title'       => __( 'Data Sheet', 'text-domain' ),
    				'priority'    => 30,
    				'callback'    => 'data_sheet_tab_content'
    			);
    			return $tabs;
    		}
    		 
    	// The new data_sheet_tab_content
    		function data_sheet_tab_content() {
    		
    		echo '<h2>Data Sheet</h2>';
    		
    	//  Left this in for info as its the clever bit that gets the datasheet url from the data_sheet custom field:
    	//	echo get_post_meta( get_the_ID(), 'data_sheet', true );
    	//
    		
    	// Puts the url on the tab, or, if empty, a message
    		
    		if( get_post_meta( get_the_ID(), 'data_sheet', true ) )
    
    		{ echo '<strong><a href="' . get_post_meta( get_the_ID(), 'data_sheet', true ) . '" target="_blank"><img style="float: left; margin-right:15px;" src="https://demo.intersafety.co.uk/wp-content/uploads/pdf.png" height="35px" width="35px">Datasheet</a></strong>';
    		}
    		else
    		{
    			echo 'No data sheet available';
    		}
    
    		}
    // ends
    

    I’ve been trying to do this, and after piecing a few functions together, here is the complete snippet from my functions.php. I’ve commented the sections. Feel free to make any tweaks if you think it could be improved. Don’t forget to add the attachment path in Other Product Options>Download & Import Attachments:

    // Upload the Data Sheet & add the url to a Custom Field (data_sheet)

    function my_attachment_uploaded($post_id, $att_id, $file) {
    $attachment_url = wp_get_attachment_url($att_id);
    update_post_meta($post_id, “data_sheet”, $attachment_url);
    }

    add_action(‘pmxi_attachment_uploaded’, ‘my_attachment_uploaded’, 10, 3);

    // Add a new tab for Data Sheets:

    add_filter( ‘woocommerce_product_tabs’, ‘data_sheet_tab’ );
    function data_sheet_tab( $tabs ) {
    // Add the new tab
    $tabs[‘data_sheet_tab’] = array(
    ‘title’ => __( ‘Data Sheet’, ‘text-domain’ ),
    ‘priority’ => 30,
    ‘callback’ => ‘data_sheet_tab_content’
    );
    return $tabs;
    }

    // The new data_sheet_tab_content
    function data_sheet_tab_content() {

    echo ‘<h2>Data Sheet</h2>’;

    // Left this in for info as its the clever bit that gets the datasheet url from the data_sheet custom field:
    // echo get_post_meta( get_the_ID(), ‘data_sheet’, true );
    //

    // Puts the url on the tab, or, if empty, a message

    if( get_post_meta( get_the_ID(), ‘data_sheet’, true ) )
    { echo ‘Datasheet‘;
    }
    else
    {
    echo ‘No data sheet available’;
    }

    }
    // ends

    I’ve been trying to do this, and after piecing a few functions together, here is the complete snippet from my functions.php. I’ve commented the sections. Feel free to make any tweaks if you think it could be improved. Don’t forget to add the attachment path in Other Product Options>Download & Import Attachments:

    // Upload the Data Sheet & add the url to a Custom Field (data_sheet)

    function my_attachment_uploaded($post_id, $att_id, $file) {
    $attachment_url = wp_get_attachment_url($att_id);
    update_post_meta($post_id, “data_sheet”, $attachment_url);
    }

    add_action(‘pmxi_attachment_uploaded’, ‘my_attachment_uploaded’, 10, 3);

    // Add a new tab for Data Sheets:

    add_filter( ‘woocommerce_product_tabs’, ‘data_sheet_tab’ );
    function data_sheet_tab( $tabs ) {
    // Add the new tab
    $tabs[‘data_sheet_tab’] = array(
    ‘title’ => __( ‘Data Sheet’, ‘text-domain’ ),
    ‘priority’ => 30,
    ‘callback’ => ‘data_sheet_tab_content’
    );
    return $tabs;
    }

    // The new data_sheet_tab_content
    function data_sheet_tab_content() {

    echo ‘<h2>Data Sheet</h2>’;

    // Left this in for info as its the clever bit that gets the datasheet url from the data_sheet custom field:
    // echo get_post_meta( get_the_ID(), ‘data_sheet’, true );
    //

    // Puts the url on the tab, or, if empty, a message

    if( get_post_meta( get_the_ID(), ‘data_sheet’, true ) )
    { echo ‘Datasheet‘;
    }
    else
    {
    echo ‘No data sheet available’;
    }

    }
    // ends

    stevebower

    (@stevebower)

    That’s exactly what I want to do 🙂
    How do I take the uploaded attachment from WPAI & display the information on a tab? (Sorry if this is a bit simple)
    Ta

    stevebower

    (@stevebower)

    Hi Many thanks for the reply.
    I’ve created the extra Downloads tab in the functions.php & this displays fine, and I’ve added the WPAllImport ‘pmxi_attachment_uploaded’ functions edit, together with the csv element in the Download & Import Attachments section. What I’m missing is the information to take the attachment content and display in the tab. I’m assuming that the html is part of this, but don’t know where. The ‘icing’ would be your last question – how to only display the tab where there is a product attachment.
    Many thanks for the help

    stevebower

    (@stevebower)

    Hi I’m looking to do exactly that same thing. Are you able to describe the steps from assigning the file in WPAI Download & Import Attachments to having it display on the tab?
    Much appreciated.

    Thread Starter stevebower

    (@stevebower)

    It’s still being erratic – 2 days, 2 orders, one at £9.99 on email, one at £10. Very strange.

    Thread Starter stevebower

    (@stevebower)

    Product prices were loaded as VAT inclusive to give the x.99 price point. Is there any reason for differences in calculations, or should we try ex-vat for the product Admin? (we’d still like to display inc VAT as it’s retail)

    Thread Starter stevebower

    (@stevebower)

    It seems to be any product at that price, but not all orders – I had one of each this morning.
    The problem seems to be that make it work, the maths has to be WRONG.
    £9.99 price gives £8.325 product, £1.665 VAT (@20%). So, to get your £9.99, the product has to be rounded down, & the VAT rounded up, or vice versa. Either way, the inconsistent treatment of the third decimal place is bad maths, unless the second decimal place is taken into account, so it starts getting complicated.

    It started happening April 4th – was that the update?

    Hmmm Nowt from CF7. Switching to Caldera.

    Thread Starter stevebower

    (@stevebower)

    Update: Defo sticking with AP All import.

    Thread Starter stevebower

    (@stevebower)

    Looks like an Android browser issue. Gone & cannot replicate

    Thread Starter stevebower

    (@stevebower)

    That worked great, thanks, but only in the Gateway parent theme css – I am running a child theme to reference custom styles. Any reason why it wouldn’t work in the child? Thanks

Viewing 15 replies - 16 through 30 (of 48 total)