Skip to content

Commit

Permalink
Adding Modal Delivery on Cart (front-end)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michel Moraes committed Oct 22, 2018
1 parent 76ad5a6 commit 14bf6a6
Show file tree
Hide file tree
Showing 28 changed files with 267 additions and 12,083 deletions.
22 changes: 10 additions & 12 deletions app/config/wp/add-options-to-database.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<?php

function MySaveOptions() {
global $woocommerce;
function my_save_options() {
$nonce = $_POST['nonce_ajax'];

$nonce = $_POST['nonce'];
// if ( ! wp_verify_nonce( $nonce, 'ajax-nonce' ) )
// die ( 'Busted!');

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

if ( $delivery_enabled == 'yes' ) {
$_SESSION['delivery'] = 'yes';
echo 'wacs_delivery_enabled option saved YES';
return;
echo 'TUDO CERTO!';
} else {
echo 'ALGO ERRADO!';
}

$_SESSION['delivery'] = 'no';
echo 'wacs_delivery_enabled option saved NO';
}
}

exit;
}
7 changes: 3 additions & 4 deletions app/config/wp/scripts-and-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@ function base_camp_scripts_and_styles()

wp_localize_script('base-camp-scripts', 'ajax_var', array(
'url' => admin_url('admin-ajax.php'),
'nonce' => wp_create_nonce('ajaxnonce')
'nonce' => wp_create_nonce('ajax-nonce')
));


// comment reply script for threaded comments
if (is_singular() && comments_open() && (get_option('thread_comments') == 1)) {
wp_enqueue_script('comment-reply');
Expand All @@ -33,8 +32,8 @@ function base_camp_scripts_and_styles()

add_action('wp_enqueue_scripts', 'base_camp_scripts_and_styles', 999);

add_action( 'wp_ajax_MySaveOptions', 'MySaveOptions' );
add_action( 'wp_ajax_nopriv_MySaveOptions', 'MySaveOptions' );
add_action( 'wp_ajax_my_save_options', 'my_save_options' );
add_action( 'wp_ajax_nopriv_my_save_options', 'my_save_options' );


/**
Expand Down
5 changes: 5 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",
"vuejs-datepicker": "^1.5.3",
"woocommerce-api": "^1.4.2"
}
}
Binary file modified resources/assets/images/placeholder-hero-02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/assets/images/placeholder-hero-03.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 35 additions & 11 deletions resources/assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,45 @@ import Slick from 'vue-slick';
import Example from './components/Example';
import Purchase from './components/Purchase';
import axios from 'axios'
import Datepicker from 'vuejs-datepicker'
import {en, ptBR} from 'vuejs-datepicker/dist/locale'

Vue.component('slick', Slick)
Vue.component('purchase', Purchase)

function defaultModalDeliveryData() {
return {
delivery: 'no',
isOpen: 'no',
type: 'hotel',
arrival_date: '',
departure_date: '',
hotel: {
name: '',
reservation: '',
customer_name: ''
},
ship: {
name: '',
cabin_number: ''
}
}
}

new Vue({
el: '#app',
components: {
Example,
Purchase
Purchase,
Datepicker
},
data() {
return {
modalDelivery: {
delivery: 'no',
isOpen: 'no'
lang: {
en,
br: ptBR
},
modalDelivery: defaultModalDeliveryData(),
registerForm: {
nationality: 'brazilian'
},
Expand Down Expand Up @@ -114,7 +137,7 @@ new Vue({
}
this.modalDelivery.isOpen = 'no'
this.modalDelivery.delivery = 'no'
this.updateCart()
this.resetModalDeliveryData()
this.saveOptionToDatabase()
},

Expand All @@ -140,26 +163,27 @@ new Vue({
},

saveOptionToDatabase() {

const data = {
action: 'MySaveOptions',
nonce: ajax_var.nonce,
action: 'my_save_options',
nonce_ajax: ajax_var.nonce,
delivery_enabled: this.modalDelivery.delivery
}

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

})
.catch(error => {
console.log(error.data)
})


},

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

}

})
Expand Down
5 changes: 4 additions & 1 deletion resources/assets/sass/_common.sass
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,7 @@ body
background: $gray-dark center / cover no-repeat

.select2-dropdown
border: 1px solid #dadada !important
border: 1px solid #dadada !important

.modal-card-foot
justify-content: space-between !important
19 changes: 19 additions & 0 deletions resources/assets/sass/components/_modal-delivery.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

.modal-delivery
&__title
border-bottom: 1px solid #cacaca
padding-bottom: 13px
color: #404040

.label
font-size: 14px
color: #545454

.modal-card-head
background-color: $primary

.modal-card-foot
background: #d6d6d6

.modal-card-title
color: #fff
2 changes: 1 addition & 1 deletion resources/assets/sass/components/_navbar.sass
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nav.navbar
width: 120px
height: auto
max-height: none !important
z-index: 999
z-index: 35
position: absolute
top: 0

Expand Down
1 change: 1 addition & 0 deletions resources/assets/sass/components/index.sass
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
@import buttons
@import custom-slick-slider
@import contact-form
@import modal-delivery
11 changes: 5 additions & 6 deletions resources/assets/sass/woocommerce/_common.sass
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ input[name='update_cart']
display: none !important

.woocommerce-message
border-top-color: #43b962
border-top-color: #43b962

.woocommerce-message::before
content: '\e015'
color: #43b962
content: '\e015'
color: #43b962

.woocommerce-cart table.cart input
margin: 10px 6px 10px
Expand All @@ -163,7 +163,6 @@ input[name='update_cart']
border-radius: 4px

.woocommerce-form-register
.select
width: 100%

.select
width: 100%

File renamed without changes.
6 changes: 6 additions & 0 deletions static/css/app.162694f3f671e63954f1.css

Large diffs are not rendered by default.

Loading

0 comments on commit 14bf6a6

Please sign in to comment.