I found this code to be very useful, how can I change it to a text that display "Product versions and period of last update" rather than a button?

Question

/**

  • Show a Live Demo button on single product page
    */
    function isa_before_add_to_cart_form() {
    global $product;
    $url = get_post_meta( $product->get_id(), ‘_isa_wc_product_demo_url’, true );
    if ( $url ) {
    echo ‘

    ‘ .
    __( ‘View Demo’, ‘textdomain’) .

    ‘;
    }
    }
    add_action(‘woocommerce_before_add_to_cart_button’,’isa_before_add_to_cart_form’,5);

/**

  • Display the Demo URL field in the Product Data metabox
    */
    function isa_wc_product_add_demo_url_field() {
    echo ”;
    woocommerce_wp_text_input(
    array(
    ‘id’ => ‘_isa_wc_product_demo_url’,
    ‘label’ => __( ‘Demo URL’, ‘textdomain’ ),
    ‘placeholder’ => ”,
    ‘desc_tip’ => ‘true’,
    ‘description’ => __( ‘Set a URL that will be displayed on the product page to link to a demo of this product. Full URL starting with "https://"’, ‘textdomain’ )
    )
    );
    echo ”;
    }
    add_action( ‘woocommerce_product_options_general_product_data’, ‘isa_wc_product_add_demo_url_field’ );

/**

  • Save the Demo URL field value when the produc is saved
    */
    function isa_wc_product_save_demo_url_value( $post_id ) {
    $val = trim( get_post_meta( $post_id, ‘_isa_wc_product_demo_url’, true ) );
    $new = sanitize_text_field( $_POST[‘_isa_wc_product_demo_url’] );
    if ( $val != $new ) {
    update_post_meta( $post_id, ‘_isa_wc_product_demo_url’, $new );
    }
    }
    add_action( ‘woocommerce_process_product_meta’, ‘isa_wc_product_save_demo_url_value’ );
0
Virtual Tech 2 months 2022-06-15T22:16:20-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse