Browse Source

Adiciona página de opção e filtros de customização.

master
Guilherme Capanema 6 years ago
parent
commit
210f437727
4 changed files with 125 additions and 26 deletions
  1. +45
    -0
      admin/class-wc-cdp-admin.php
  2. +3
    -0
      includes/class-wc-cdp.php
  3. +52
    -0
      public/css/wc-cdp-public.css
  4. +25
    -26
      public/partials/product-bundle-modal.php

+ 45
- 0
admin/class-wc-cdp-admin.php View File

@ -100,6 +100,51 @@ class Wc_Cdp_Admin {
} }
/**
* Adds the plugin's settings page under WooCommerce's Products tab
*
* @since 1.0.0
*/
public function add_settings_tab( $sections )
{
$sections['wc-cdp'] = __( 'Combos de produtos', 'wc-cdp' );
return $sections;
}
public function display_settings_tab( $settings, $current_section )
{
if ( $current_section == 'wc-cdp' ) {
$settings_wc_cdp = array();
$settings_wc_cdp[] = array( 'name' => __( 'Combos de produtos', 'wc-cdp' ), 'type' => 'title', 'desc' => __( 'As opções a seguir são usadas para configurar os combos de produtos', 'wc-cdp' ), 'id' => 'wcslider' );
$settings_wc_cdp[] = array(
'name' => __( 'Título do popup', 'wc-cdp' ),
'id' => 'wc_cdp_title',
'type' => 'text',
);
$settings_wc_cdp[] = array(
'name' => __( 'Descrição do popup', 'wc-cdp' ),
'id' => 'wc_cdp_description',
'type' => 'textarea',
'desc_tip' => __( 'É exibida logo abaixo do título, antes dos produtos do combo', 'wc-cdp' ),
);
$settings_wc_cdp[] = array(
'name' => __( 'Texto do botão', 'wc-cdp' ),
'id' => 'wc_cdp_add_to_cart_text',
'type' => 'text',
);
$settings_wc_cdp[] = array( 'type' => 'sectionend', 'id' => 'wc-cdp' );
return $settings_wc_cdp;
} else {
return $settings;
}
}
/** /**
* Adds bundled products fields to the WooCoommerce metabox * Adds bundled products fields to the WooCoommerce metabox
* *


+ 3
- 0
includes/class-wc-cdp.php View File

@ -157,6 +157,9 @@ class Wc_Cdp {
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' ); $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$this->loader->add_action( 'woocommerce_get_sections_products', $plugin_admin, 'add_settings_tab' );
$this->loader->add_action( 'woocommerce_get_settings_products', $plugin_admin, 'display_settings_tab', 10, 2 );
$this->loader->add_action( 'woocommerce_product_options_related', $plugin_admin, 'display_product_fields' ); $this->loader->add_action( 'woocommerce_product_options_related', $plugin_admin, 'display_product_fields' );
$this->loader->add_action( 'woocommerce_process_product_meta', $plugin_admin, 'save_product_fields' ); $this->loader->add_action( 'woocommerce_process_product_meta', $plugin_admin, 'save_product_fields' );


+ 52
- 0
public/css/wc-cdp-public.css View File

@ -7,3 +7,55 @@
width: 100%; width: 100%;
height: auto; height: auto;
} }
.wc_cdp_modal_title,
.wc_cdp_modal_description,
.wc_cdp_modal_product_title,
.wc_cdp_modal_product_already_on_cart,
.wc_cdp_bundle_amount,
.wc_cdp_bundle_action_row {
text-align: center;
}
.wc_cdp_modal_product_title {
font-size: 1rem;
margin-top: 0.5rem;
}
.wc_cdp_modal_product_separator {
text-align: center;
font-size: 2rem;
font-weight: bold;
}
.wc_cdp_bundle_amount {
margin-bottom: 1rem;
}
@media (min-width: 768px) {
.wc_cdp_modal_products_row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: center;
margin-left: -15px;
margin-right: -15px;
}
.wc_cdp_modal_product {
flex: 0 0 25%;
max-width: 25%;
align-self: stretch;
padding-left: 15px;
padding-right: 15px;
}
.wc_cdp_modal_product_separator {
flex: 0 0 auto;
width: auto;
max-width: 100%;
padding-right: 15px;
padding-left: 15px;
}
}

+ 25
- 26
public/partials/product-bundle-modal.php View File

@ -29,40 +29,37 @@
<h2 class="font-weight-normal letter-spacing-2 mb-2 text-center" id="wc_cdp_product_bundle_modal_label">
<span class="text-line-warning d-lg-block px-4 px-lg-0">
Fazer parzinho é mais legal!
</span>
<h2 class="<?php echo apply_filters( 'wc_cdp_modal_title_class', 'wc_cdp_modal_title' ); ?>" id="wc_cdp_product_bundle_modal_label">
<?php echo get_option( 'wc_cdp_title' ); ?>
</h2> </h2>
<p class="text-muted text-center mb-5">
eu ouvi desconto? é adicionar os itens abaixo e aproveitar o valor promocional!
<p class="<?php echo apply_filters( 'wc_cdp_modal_description_class', 'wc_cdp_modal_description' ); ?>">
<?php echo get_option( 'wc_cdp_description' ); ?>
</p> </p>
<form action="<?php echo get_admin_url(); ?>admin-post.php" method="POST"> <form action="<?php echo get_admin_url(); ?>admin-post.php" method="POST">
<div class="row align-items-center justify-content-center mb-3">
<div class="<?php echo apply_filters( 'wc_cdp_modal_products_row_class', 'wc_cdp_modal_products_row' ); ?>">
<?php foreach ($bundle_products as $key => $bundle_product) : ?> <?php foreach ($bundle_products as $key => $bundle_product) : ?>
<div class="col-lg-3 align-self-stretch">
<div class="<?php echo apply_filters( 'wc_cdp_modal_product_class', 'wc_cdp_modal_product' ); ?>">
<?php echo $bundle_product->get_image(); ?> <?php echo $bundle_product->get_image(); ?>
<h6 class="text-uppercase font-weight-bold text-center mt-2">
<h3 class="<?php echo apply_filters( 'wc_cdp_modal_product_title_class', 'wc_cdp_modal_product_title' ); ?>">
<?php echo $bundle_product->get_title(); ?> <?php echo $bundle_product->get_title(); ?>
</h6>
</h3>
<?php <?php
$product_cart_id = WC()->cart->generate_cart_id( $bundle_product->get_id() ); $product_cart_id = WC()->cart->generate_cart_id( $bundle_product->get_id() );
if ( WC()->cart->find_product_in_cart( $product_cart_id ) ) : if ( WC()->cart->find_product_in_cart( $product_cart_id ) ) :
?> ?>
<p class="text-success text-center">
<p class="<?php echo apply_filters( 'wc_cdp_already_on_cart_class', 'wc_cdp_modal_product_already_on_cart' ); ?>">
<small> <small>
( está na sua cestinha)
<?php echo apply_filters( 'wc_cdp_already_on_cart_text', __('(já está no seu carrinho)', 'wc-cdp') ); ?>
</small> </small>
</p> </p>
<?php else: ?> <?php else: ?>
@ -75,10 +72,8 @@
<?php if ( $key !== array_key_last($bundle_products) ): ?> <?php if ( $key !== array_key_last($bundle_products) ): ?>
<div class="col-lg-auto">
<h2 class="font-weight-bold text-primary m-0">
<div class="<?php echo apply_filters( 'wc_cdp_modal_product_separator_class', 'wc_cdp_modal_product_separator' ); ?>">
+ +
</h2>
</div> </div>
<?php endif; ?> <?php endif; ?>
@ -87,24 +82,28 @@
</div> </div>
<div class="text-center mb-3 wc_cdp_bundle_amount">
<del>
<?php echo wc_price($bundle_regular_price); ?>
</del>
<div class="<?php echo apply_filters( 'wc_cdp_bundle_amount_class', 'wc_cdp_bundle_amount' ); ?>">
<?php if ($bundle_discount_price): ?>
<del>
<?php echo wc_price($bundle_regular_price); ?>
</del>
<ins>
<?php echo wc_price($bundle_discount_price); ?>
</ins>
<ins>
<?php echo wc_price($bundle_discount_price); ?>
</ins>
<?php else: ?>
<?php echo wc_price($bundle_regular_price); ?>
<?php endif; ?>
</div> </div>
<div class="text-center">
<div class="<?php echo apply_filters( 'wc_cdp_bundle_action_row_class', 'wc_cdp_bundle_action_row' ); ?>">
<input type="hidden" name="action" value="wc_cdp_add_to_cart" /> <input type="hidden" name="action" value="wc_cdp_add_to_cart" />
<input type="hidden" name="wc_cdp_bundle_coupon" value="<?php echo $bundle_coupon->get_code(); ?>" /> <input type="hidden" name="wc_cdp_bundle_coupon" value="<?php echo $bundle_coupon->get_code(); ?>" />
<button type="submit" class="btn btn-primary text-uppercase text-white font-weight-bold py-1">
Colocar todos na cestinha!
<button type="submit" class="<?php echo apply_filters( 'wc_cdp_add_to_cart_button_class', 'button wc-forward alt wc_cdp_add_to_cart_button' ); ?>">
<?php echo apply_filters( 'wc_cdp_add_to_cart_text', get_option( 'wc_cdp_add_to_cart_text' ) ); ?>
</button> </button>
</div> </div>


Loading…
Cancel
Save