使用PrestaShop在PHP中打开一个新窗口

时间:2017-12-08 11:58:26

标签: php prestashop prestashop-1.6

我需要帮助打开一个新窗口,执行验证码。问题是我在运行下一个PHP文件时需要这个。

<?php

class hhpaymentvalidationModuleFrontController extends ModuleFrontController
{


    /**
     * Validation du paiement standard
     * Puis redirection vers la page de succès de commande
     */
    public function postProcess()
    {
         $cart = $this->context->cart;

       $this->abrir("http://davivienda.com");
//       0abrir("http://davivienda.com");


        if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
            Tools::redirect('index.php?controller=order&step=1');
        }

        $customer = new Customer($cart->id_customer);

        if (!Validate::isLoadedObject($customer)) {
            Tools::redirect('index.php?controller=order&step=1');
        }

        $currency = $this->context->currency;
        $total = (float)$cart->getOrderTotal(true, Cart::BOTH);

        //La command passe directement en statut payé
        $this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, array(), (int)$currency->id, false, $customer->secure_key);
        Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
    }

public function abrir( $param ) 
  {

    echo '<script type="text/javascript">';
    echo "window.open( '{$param}', 'ventana1', 'scrollbars=0, width=300, height=300' )";
    echo '</script>';  
  } 

}

1 个答案:

答案 0 :(得分:0)

您无法通过PHP脚本打开新窗口/选项卡,因为它是服务器端语言。但是您可以在重定向网址中传递一些变量并在客户端使用它。像

Tools::redirect('index.php?controller=order&step=1&popup=1');

然后使用jQuery打开带有您的URL的新窗口

$(document).ready(function() {
  let searchParams = new URLSearchParams(window.location.search);
  if (searchParams.has('popup')) {
    window.open('Your URL', 'window name', 'window settings')
  }
});