Exemplo n.º 1
0
 protected function filtros_precio($precio = false)
 {
     if (!$precio) {
         $precio = (double) get_post_meta($this->id, '_precio', true);
     }
     if (is_user_logged_in()) {
         /*
          **SI HAY USUARIO LOGUEADO REVISAMOS
          **SI TIENE CUPONES
          */
         $cupones = Cupon::get_cupones($this->comprador);
         if ($cupones) {
             foreach ($cupones as $identificador => $setting) {
                 $cupon = new Cupon($identificador);
                 $mensaje_cupon = $cupon->get_mensajes();
                 if ($mensaje_cupon->ok) {
                     /*
                      **SI NO HAY ERRORES EN EL CUPÓN seteamos
                      **PRECIO
                      */
                     $precio -= $cupon->get_descuento();
                     if ($precio < 0) {
                         $precio = 0;
                     }
                 }
             }
         }
     }
     return $precio;
 }
Exemplo n.º 2
0
 public function finalizar_compra($guardar_tarjeta = false)
 {
     /*
      **EN CASO DE NO HABER PRECIO Y NO HABER PRODUCTOS
      **NOS VAMOS
      */
     if (!isset($this->paquete->data['precio']) && !$this->productos) {
         return;
     }
     /*SETEAMOS EL METODO FINAL DE PAGO*/
     $pago = $this->metodos_pago['conekta'];
     /*facilitamos el acceso en una variable*/
     $pago->set_monto($this->paquete, $this->productos);
     $pago->set_comprador($this->comprador);
     $pago->set_clases($this->paquete->data['cantidad']);
     $pago->procesar_compra($this->invitado, $guardar_tarjeta);
     if (!$pago->mensajes->ok) {
         foreach ($pago->mensajes->mensajes as $mensaje) {
             $this->mensaje->add_error($mensaje);
         }
         return;
     }
     check_codigo_activacion($this->comprador);
     if ($this->invitado) {
         $this->procesar_invitado($this->invitado, $this->comprador);
     }
     if (!$this->gift_card) {
         update_user_meta($this->comprador, 'ya_compro', true);
         /*ACTUALIZAMOS PARA QUE SE MUESTRE QUE YA REALIZÓ UNA COMPRA*/
     }
     if (Cupon::get_cupones($this->comprador)) {
         Cupon::eliminar_cupones($this->comprador);
     }
     $this->redirect = array('infopedido' => $pago->idPedido);
 }
Exemplo n.º 3
0
 public static function eliminar_cupones($user_id = false)
 {
     if (!$user_id) {
         return;
     }
     /*
      **Debemos añadir al registro el usuarios que usaron
      */
     $cupones = Cupon::get_cupones($user_id);
     if ($cupones) {
         foreach ($cupones as $id => $xx) {
             $cupon = new Cupon($id);
             $errores = $cupon->get_mensajes();
             if ($errores->ok) {
                 $cupon->annadir_uso($user_id);
             }
         }
     }
     return update_user_meta($user_id, 'cupones_aplicados', null);
 }