Title: Add second buy button
Last modified: May 22, 2018

---

# Add second buy button

 *  Resolved [saribri](https://wordpress.org/support/users/saribri/)
 * (@saribri)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/add-second-buy-button/)
 * 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](https://wordpress.org/support/users/saribri/)
 * (@saribri)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/add-second-buy-button/#post-10313225)
 * 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 7 years, 11 months ago by [saribri](https://wordpress.org/support/users/saribri/).
    -  This reply was modified 7 years, 11 months ago by [saribri](https://wordpress.org/support/users/saribri/).
 *  Plugin Author [leonmagee](https://wordpress.org/support/users/leonmagee/)
 * (@leonmagee)
 * [7 years, 11 months ago](https://wordpress.org/support/topic/add-second-buy-button/#post-10323487)
 * [@saribri](https://wordpress.org/support/users/saribri/) that’s good to know.
   I didn’t think of having two buttons. Let me know if you need more help with 
   this.
 *  [chanduram4](https://wordpress.org/support/users/chanduram4/)
 * (@chanduram4)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/add-second-buy-button/#post-10435445)
 * [@saribri](https://wordpress.org/support/users/saribri/) [@leonmagee](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/shop-page-wp/assets/icon-256x256.png?rev=1621159)
 * [Shop Page WP](https://wordpress.org/plugins/shop-page-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shop-page-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shop-page-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/shop-page-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shop-page-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shop-page-wp/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [chanduram4](https://wordpress.org/support/users/chanduram4/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/add-second-buy-button/#post-10435445)
 * Status: resolved