Skip to content

Commit

Permalink
Adding new Modal Delivery configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Moraes committed Oct 23, 2018
1 parent 66a76b8 commit d340290
Show file tree
Hide file tree
Showing 16 changed files with 183 additions and 38 deletions.
35 changes: 23 additions & 12 deletions app/config/wp/add-options-to-database.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
<?php

function my_save_options() {
$nonce = $_POST['nonce_ajax'];
// $nonce = $_POST['nonce_ajax'];

$delivery_enabled = $_POST['delivery_enabled'];

WC()->session->custom_delivery = $delivery_enabled;
// var_dump(WC()->session->custom_delivery);

wp_send_json( array( 'success' => true, 'message' => 'Saved', 'val' => $delivery_enabled ) );

// if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) )
// die ( 'Busted!');

if ( isset($_POST['delivery_enabled']) ) {
$delivery_enabled = $_POST['delivery_enabled'];
// update_option('wacs_delivery_enabled', $delivery_enabled);

if ( $delivery_enabled == 'yes' ) {
echo 'TUDO CERTO!';
} else {
echo 'ALGO ERRADO!';
}
}
// if ( isset($_POST['delivery_enabled']) ) {
// $delivery_enabled = $_POST['delivery_enabled'];
// // update_option('wacs_delivery_enabled', $delivery_enabled);

// if ( $delivery_enabled == 'yes' ) {
// echo 'TUDO CERTO!';
// } else {
// echo 'ALGO ERRADO!';
// }
// }

exit;

}



function before_checkout_create_order( $order, $data ) {
var_dump($data);
var_dump($order);

$order->update_meta_data( '_custom_meta_key', 'value' );
}

Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"i": "^0.3.6",
"jquery": "^3.3.1",
"vue": "^2.5.16",
"vue-cookie": "^1.1.4",
"vuejs-datepicker": "^1.5.3",
"woocommerce-api": "^1.4.2"
}
Expand Down
27 changes: 20 additions & 7 deletions resources/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Purchase from './components/Purchase';
import axios from 'axios'
import Datepicker from 'vuejs-datepicker'
import {en, ptBR} from 'vuejs-datepicker/dist/locale'
import VueCookie from 'vue-cookie'
Vue.use(VueCookie)

Vue.component('slick', Slick)
Vue.component('purchase', Purchase)
Expand Down Expand Up @@ -41,6 +43,7 @@ new Vue({
en,
br: ptBR
},
openModal: false,
modalDelivery: defaultModalDeliveryData(),
registerForm: {
nationality: 'brazilian'
Expand Down Expand Up @@ -120,23 +123,33 @@ new Vue({

mounted() {
this.updateCartOnChangeQuantity()

},

created() {
this.modalDelivery.delivery = this.$cookie.get('custom_delivery')
},

methods: {
openDeliveryModal() {
this.modalDelivery.isOpen = 'yes'
this.openModal = true
},

closeDeliveryModal(action) {
if (action == 'save') {
this.openModal = false
this.modalDelivery.isOpen = 'no'
this.modalDelivery.delivery = 'yes'
this.$cookie.set('custom_delivery', 'yes')
this.updateCart()
this.saveOptionToDatabase()
return
}
this.openModal = false
this.modalDelivery.isOpen = 'no'
this.modalDelivery.delivery = 'no'
this.$cookie.set('custom_delivery', 'no')
this.updateCart()
this.resetModalDeliveryData()
this.saveOptionToDatabase()
},
Expand Down Expand Up @@ -166,23 +179,23 @@ new Vue({
const data = {
action: 'my_save_options',
nonce_ajax: ajax_var.nonce,
delivery_enabled: this.modalDelivery.delivery
delivery_enabled: this.modalDelivery.delivery,
}

axios
.post(ajax_var.url, $.param(data))
.then(res => {
console.log(res.data)

window.location.reload(true)
})
.catch(error => {
console.log(error.data)
})
},

resetModalDeliveryData: function (){
this.$data.modalDelivery = defaultModalDeliveryData();
}
resetModalDeliveryData: function (){
this.$data.modalDelivery = defaultModalDeliveryData();
}

}

Expand All @@ -193,4 +206,4 @@ $(window).on('load', () => $('.pageloader').removeClass('is-active'))

// Toggle mobile menu
$('.navbar-burger').on('click', () =>
$('.navbar-burger, .navbar-menu').toggleClass('is-active'))
$('.navbar-burger, .navbar-menu').toggleClass('is-active'))
2 changes: 0 additions & 2 deletions resources/assets/sass/pages/_tickets.sass
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@

.tickets

.intro

&__title
font-family: $font-title
font-size: 28px
Expand Down
1 change: 1 addition & 0 deletions resources/views/header/_head.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<meta name="description" content="{{ site.description }}">

<link rel="pingback" href="{{ site.pingback_url }}"/>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">

{{ function('wp_head') }}
</head>
File renamed without changes.
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Loading

0 comments on commit d340290

Please sign in to comment.