我已经创建了一个插件
插件替换“添加到购物车”按钮,弹出“继续”按钮。对于店主选择的每一种产品
我希望在单击按钮时将用户重定向到我的自定义页面。我需要页面将显示不同产品id的不同内容。我应该将页面放在插件文件夹中的什么位置?
如何重定向到它?
我需要该页面将使用商店主题,例如,我希望该页面将显示产品页面的原样,通过获取url中的产品id…
代码是用id替换按钮的功能。
function replacing_add_to_cart_button( $button, $product  ) {
  $product_id = $product->get_id();
  //
  global $wpdb;
  $shopName = getShopName();
  $existQuary = "SELECT * FROM `wp_onePlusOne` WHERE `id` = \'$product_id\'";
  $existQuaryRes = $wpdb->get_results($existQuary);//simplafy query
  if(!empty($existQuaryRes)){
    $id_onePlusOne = get_object_vars($existQuaryRes[0])[\'id\'];
    $button_text = __("1+1", "woocommerce");
    $button ="<div>".$button."
    <button id=\'myBtn".$id_onePlusOne."\' onclick=\'display".$id_onePlusOne."()\'>1+1</button>
      <div id=\'myModal".$id_onePlusOne."\' class=\'modal\'>
        <div class=\'modal-content".$id_onePlusOne."\'>
          <span id=\'close".$id_onePlusOne."\' class=\'close".$id_onePlusOne."\'  onclick=\'spanDisplay".$id_onePlusOne."()\'>×</span>
          <p id=\'".$id_onePlusOne."\'><a href=\'http://linlRedirectTo."/".$id_onePlusOne."\'  onclick=\'unDisplay".$id_onePlusOne."()\' target=\'_blank\'>" . $button_text . \'</a>\'  ."</p>
        </div>
      </div>
      <style>
      .modal {
          display: none;
          position: fixed;
          z-index: 1;
          padding-top: 100px;
          left: 0;
          top: 0;
          width: 100%;
          height: 100%;
          overflow: auto;
          background-color: rgb(0,0,0);
          background-color: rgba(0,0,0,0.4);
      }
      .modal-content".$id_onePlusOne." {
          background-color: #fefefe;
          margin: auto;
          padding: 20px;
          border: 1px solid #888;
          width: 80%;
      }
      .close".$id_onePlusOne." {
          color: #aaaaaa;
          float: right;
          font-size: 28px;
          font-weight: bold;
      }
      .close".$id_onePlusOne.":hover,
      .close".$id_onePlusOne.":focus {
          color: #000;
          text-decoration: none;
          cursor: pointer;
      }
      </style>
    <script>
    function display".$id_onePlusOne."() {
        document.getElementById(\'myModal".$id_onePlusOne."\').style.display = \'block\';
    }
    function unDisplay".$id_onePlusOne."() {
        document.getElementById(\'myModal".$id_onePlusOne."\').style.display = \'none\';
    }
    function spanDisplay".$id_onePlusOne."() {
        document.getElementById(\'myModal".$id_onePlusOne."\').style.display = \'none\';
    }
    window.onclick = function(event) {
        if (event.target == document.getElementById(\'myModal".$id_onePlusOne."\')) {
            document.getElementById(\'myModal".$id_onePlusOne."\').style.display = \'none\';
        }
    }
    </script></div>" ;
  }
  return $button;
}
 谢谢你!!!