HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/self/cwd/wp-content/plugins/coordinadora/includes/Coordinadora_WC_Droop_Shipping.php
<?php
class Coordinadora_WC_Droop_Shipping
{
  private $droopApiKey;
  private $droopCustomLogoSrc;
  private $droopEnabled;


  public function __construct()
  {
    $shippingSettings = get_option('woocommerce_coordinadora_settings');
    if (isset($shippingSettings['droop_api_key']) &&  isset($shippingSettings['droop_custom_logo_url'])) {
      $this->droopApiKey = $shippingSettings['droop_api_key'];
      $this->droopCustomLogoSrc = $shippingSettings['droop_custom_logo_url'];
      $this->droopEnabled = isset($shippingSettings['droop_enabled']) ? $shippingSettings['droop_enabled'] : 'no';
    }
  }

  public function init()
  {
    add_action('wp_enqueue_scripts', array($this, 'add_coordinadora_wc_droop_js'));
    add_action('woocommerce_form_field_text', array($this, 'coordinadora_wc_add_droop_form_field'), 10, 4);
  }

  public function add_coordinadora_wc_droop_js()
  {
    wp_register_script(
      'droop',
      plugins_url('../assets/js/droop.js', __FILE__),
      array('jquery')
    );

    wp_enqueue_script('droop');

    wp_localize_script(
      'droop',
      'coordinadoraShippingSettings',
      array(
        'droopApiKey' => $this->droopApiKey,
        'droopEnabled' => $this->droopEnabled
      )
    );
  }

  public function coordinadora_wc_add_droop_form_field($field, $key, $args, $value)
  {
    if (is_checkout() && isset($this->droopEnabled) && $this->droopEnabled == "yes" && $this->droopApiKey && isset($this->droopCustomLogoSrc) && ($key == 'billing_address_1' || $key == 'shipping_address_1')) {
      $field .= '
          <p class="form-row">
            <label for="wc-droop-coordinadora">Selecciona un punto Droop Coordinadora para la entrega (opcional)</label>
            <puntos-drop id="wc-droop-coordinadora" entry-parameter="' . $this->droopApiKey . '" logo-comercio="' . $this->droopCustomLogoSrc . '"></puntos-drop>
          <p>';
    }
    return $field;
  }
}