• Resolved saribri

    (@saribri)


    Hello,

    I would like to add a second Buy button so users will have an option between local/international seller. Here’s what I did so far:

    Added field in class-shop-page-wp-cmb2.php

    $cmb_url->add_field( array(
    	'name' => esc_html__( 'Product Affiliate URL Secondary', 'cmb2' ),
    	'id'   => $prefix . 'url_secondary',
    	'type' => 'text_url',
    ) );

    Updated class-shop-page-wp-grid.php:
    in while ( $shop_page_wp_query->have_posts()
    $url_secondary_field = $prefix . 'url_secondary';

    if ( ! ( $link = get_post_meta( get_the_ID(), $url_secondary_field, true ) ) ) {
    	$link_secondary = false;
    }

    I noticed that $link_secondary returns null. What else do I need to update for the actual saving?
    Thanks a lot.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter saribri

    (@saribri)

    I found what I did wrong. Should’ve set the to $link_secondary.

    if ( ! ( $link_secondary = get_post_meta( get_the_ID(), $url_secondary_field, true ) ) ) {
    	$link_secondary = false;
    }
    • This reply was modified 6 years, 6 months ago by saribri.
    • This reply was modified 6 years, 6 months ago by saribri.
    Plugin Author leonmagee

    (@leonmagee)

    @saribri that’s good to know. I didn’t think of having two buttons. Let me know if you need more help with this.

    @saribri @leonmagee Can anyone of you help me with the complete code and process in detail to add an optional(just like how short description field is given as optional) secondary button with URL to this plugin. Thank you in Advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add second buy button’ is closed to new replies.