Skip to content

Commit

Permalink
Adiciona plano da Vindi nas Assinaturas Variáveis (#118)
Browse files Browse the repository at this point in the history
* Adicionado plano da Vindi nas variações

* Adicionado plano padrão da Vindi na aba geral para assinaturas variáveis

* Alterado nome do campo do plano de variação

* Corrigido bug que não trocava de 12 meses para 1 ano nas variações

* Adicionado novo hook para Assinatura Simples

* Assinaturas simples salvam o valor conforme o plano da vindi.

* Versão 5.5.0
  • Loading branch information
soareseneves authored and laerte-guimaraes committed Jun 5, 2019
1 parent 5eae7c3 commit 2123811
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 73 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Notas das versões

## [5.5.0 - 04/06/2019](https://github.com/vindi/vindi-woocommerce-subscriptions/releases/tag/5.5.0)

### Adicionado
- Adiciona plano da Vindi para assinaturas do tipo variável


## [5.4.2 - 13/03/2019](https://github.com/vindi/vindi-woocommerce-subscriptions/releases/tag/5.4.3)

### Ajustado
Expand Down
17 changes: 12 additions & 5 deletions assets/js/simple-subscription-fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
var id = $(this).val();
var plan = plan_infos[id];

console.log($(".wc_input_subscription_period_interval"));

$(".wc_input_subscription_period_interval").val(plan.interval_count);
$(".wc_input_subscription_period").val(plan.interval.toString().replace(/s/g, ''));
$(".wc_input_subscription_length").val(plan.billing_cycles || 0);
$("#_subscription_period_interval").val(plan.interval_count);
$("#_subscription_period").val(plan.interval.toString().replace(/s/g, ''));
$("#_subscription_length").val(plan.billing_cycles || 0);
});

$(document).on("change", ".variable_vindi_subscription_plan", function(){
var id = $(this).val();
var plan = plan_infos[id];

$(this).parents(".data").find(".wc_input_subscription_period_interval").val(plan.interval_count);
$(this).parents(".data").find(".wc_input_subscription_period").val(plan.interval.toString().replace(/s/g, ''));
$(this).parents(".data").find(".wc_input_subscription_length").val(plan.billing_cycles || 0);
});
});
}(jQuery)
Expand Down
10 changes: 9 additions & 1 deletion includes/class-vindi-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ public function get_plan()

foreach($items as $item) {
$product = $this->order->get_product_from_item($item);
$vindi_plan = get_post_meta($product->id, 'vindi_subscription_plan', true);

if (isset($item['variation_id']) && $item['variation_id'] != 0) {
$vindi_plan = get_post_meta($item['variation_id'], 'vindi_variable_subscription_plan', true);
if (empty($vindi_plan) || !is_numeric($vindi_plan) || is_null($vindi_plan) || $vindi_plan == 0){
$vindi_plan = get_post_meta($product->id, 'vindi_subscription_plan', true);
}
}
else
$vindi_plan = get_post_meta($product->id, 'vindi_subscription_plan', true);

if ($this->is_subscription_type($product) AND !empty($vindi_plan))
return $vindi_plan;
Expand Down
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ Contributors: erico.pedroso, tales.galvao.vindi, wnarde, lyoncesar, laertejr, rt
Website Link: https://www.vindi.com.br
Tags: vindi, subscriptions, pagamento-recorrente, cobranca-recorrente, cobrança-recorrente, recurring, site-de-assinatura, assinaturas, faturamento-recorrente, recorrencia, assinatura, woocommerce-subscriptions, vindi-woocommerce
Requires at least: 4.4
Tested up to: 4.9.8
Tested up to: 5.2.1
WC requires at least: 3.0.0
WC tested up to: 3.4.5
Stable Tag: 5.4.2
WC tested up to: 3.6.4
Stable Tag: 5.5.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -63,6 +63,9 @@ Caso necessite de informações sobre a plataforma ou API por favor siga atravé

== Changelog ==

= 5.5.0 - 04/06/2019 =
- Adiciona plano da Vindi para assinaturas do tipo variável

= 5.4.2 - 13/03/2019 =
- Ajusta validação dos dados da empresa durante o checkout

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@
display: none !important;
}
</style>

<div class="options_group vindi-subscription_pricing show_if_subscription show_if_variable-subscription">

<?php

if (preg_match('/variable-subscription/', $product_type)) {
$label = __('Plano padrão da Vindi', VINDI_IDENTIFIER);
$description = __('Selecione o plano padrão da Vindi que deseja relacionar a esse produto caso não especifique na variação', VINDI_IDENTIFIER);
} else {
$label = __('Plano da Vindi', VINDI_IDENTIFIER);
$description = __('Selecione o plano da Vindi que deseja relacionar a esse produto', VINDI_IDENTIFIER);
}

woocommerce_wp_select(array(
'id' => 'vindi_subscription_plan',
'label' => __('Plano da Vindi', VINDI_IDENTIFIER),
'label' => $label,
'options' => $plans['names'],
'description' => __('Selecione o plano da Vindi que deseja relacionar a esse produto', VINDI_IDENTIFIER),
'description' => $description,
'desc_tip' => true,
'value' => $selected_plan,
'custom_attributes' => array(
Expand Down
16 changes: 16 additions & 0 deletions templates/admin-variable-product-subscription-fields.html.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php if (!defined( 'ABSPATH')) exit; ?>
<div class="options_group vindi-subscription_pricing show_if_variable-subscription">

<?php
woocommerce_wp_select(array(
'id' => 'vindi_variable_subscription_plan[' . $loop . ']',
'label' => __('Plano da Vindi', VINDI_IDENTIFIER),
'options' => $plans['names'],
'description' => __('Selecione o plano da Vindi que deseja relacionar a esse produto', VINDI_IDENTIFIER),
'desc_tip' => true,
'value' => $selected_plan,
'class' => 'select short variable_vindi_subscription_plan'
));
?>
</div>
<div class="show_if_subscription clear"></div>
Loading

0 comments on commit 2123811

Please sign in to comment.