Commit 7ac9af42 authored by Telenkov Ruslan's avatar Telenkov Ruslan

modal commerce done

parent e991cdc6
......@@ -15,6 +15,7 @@
"cweagans/composer-patches": "^1.6",
"drupal/admin_toolbar": "^2.4",
"drupal/commerce": "^2.30",
"drupal/commerce_cart_api": "^1.5",
"drupal/config_ignore": "^2.3",
"drupal/core": "^9.1",
"drupal/core-composer-scaffold": "^9",
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "10f72fd1d0ca1ed1fc5be1720a08f697",
"content-hash": "4d839eaa25886d1f5012f97572ef9101",
"packages": [
{
"name": "asm89/stack-cors",
......@@ -2082,6 +2082,380 @@
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_cart",
"version": "2.30.0",
"require": {
"drupal/commerce": "*",
"drupal/commerce_order": "*",
"drupal/commerce_product": "*",
"drupal/core": "^9.2 || ^10"
},
"type": "metapackage",
"extra": {
"drupal": {
"version": "8.x-2.30",
"datestamp": "1649341535",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "bojanz",
"homepage": "https://www.drupal.org/user/86106"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Implements the shopping cart system and add to cart features.",
"homepage": "https://www.drupal.org/project/commerce",
"support": {
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_cart_api",
"version": "1.5.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/commerce_cart_api.git",
"reference": "8.x-1.5"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/commerce_cart_api-8.x-1.5.zip",
"reference": "8.x-1.5",
"shasum": "f9d39e55ddf6d533bdfc15c217e0954b1334e21d"
},
"require": {
"drupal/commerce": "^2.13",
"drupal/commerce_cart": "*",
"drupal/core": "^8.8 || ^9"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-1.5",
"datestamp": "1611244293",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "attisan",
"homepage": "https://www.drupal.org/user/2041338"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
}
],
"description": "Provides a RESTful interface to interact with carts in Drupal Commerce via a lightweight public API.",
"homepage": "https://www.drupal.org/project/commerce_cart_api",
"keywords": [
"Drupal"
],
"support": {
"source": "http://cgit.drupalcode.org/commerce_cart_api",
"issues": "https://www.drupal.org/project/issues/commerce_cart_api"
}
},
{
"name": "drupal/commerce_number_pattern",
"version": "2.30.0",
"require": {
"drupal/commerce": "*",
"drupal/commerce_store": "*",
"drupal/core": "^9.2 || ^10"
},
"type": "metapackage",
"extra": {
"drupal": {
"version": "8.x-2.30",
"datestamp": "1649341535",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "bojanz",
"homepage": "https://www.drupal.org/user/86106"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Provides configurable patterns for generating sequential numbers.",
"homepage": "https://www.drupal.org/project/commerce",
"support": {
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_order",
"version": "2.30.0",
"require": {
"drupal/commerce": "*",
"drupal/commerce_number_pattern": "*",
"drupal/commerce_price": "*",
"drupal/commerce_store": "*",
"drupal/core": "^9.2 || ^10",
"drupal/entity_reference_revisions": "*",
"drupal/profile": "*",
"drupal/state_machine": "*"
},
"type": "metapackage",
"extra": {
"drupal": {
"version": "8.x-2.30",
"datestamp": "1649341535",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "bojanz",
"homepage": "https://www.drupal.org/user/86106"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Defines the Order entity and associated features.",
"homepage": "https://www.drupal.org/project/commerce",
"support": {
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_price",
"version": "2.30.0",
"require": {
"drupal/commerce": "*",
"drupal/core": "^9.2 || ^10"
},
"type": "metapackage",
"extra": {
"drupal": {
"version": "8.x-2.30",
"datestamp": "1649341535",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "bojanz",
"homepage": "https://www.drupal.org/user/86106"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Defines the Currency entity.",
"homepage": "https://www.drupal.org/project/commerce",
"support": {
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_product",
"version": "2.30.0",
"require": {
"drupal/commerce": "*",
"drupal/commerce_price": "*",
"drupal/commerce_store": "*",
"drupal/core": "^9.2 || ^10"
},
"type": "metapackage",
"extra": {
"drupal": {
"version": "8.x-2.30",
"datestamp": "1649341535",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "bojanz",
"homepage": "https://www.drupal.org/user/86106"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Defines the Product entity and associated features.",
"homepage": "https://www.drupal.org/project/commerce",
"support": {
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/commerce_store",
"version": "2.30.0",
"require": {
"drupal/commerce": "*",
"drupal/commerce_price": "*",
"drupal/core": "^9.2 || ^10"
},
"type": "metapackage",
"extra": {
"drupal": {
"version": "8.x-2.30",
"datestamp": "1649341535",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Centarro",
"homepage": "https://www.drupal.org/user/3661446"
},
{
"name": "bojanz",
"homepage": "https://www.drupal.org/user/86106"
},
{
"name": "jsacksick",
"homepage": "https://www.drupal.org/user/972218"
},
{
"name": "mglaman",
"homepage": "https://www.drupal.org/user/2416470"
},
{
"name": "rszrama",
"homepage": "https://www.drupal.org/user/49344"
}
],
"description": "Defines the Store entity and associated features.",
"homepage": "https://www.drupal.org/project/commerce",
"support": {
"source": "https://git.drupalcode.org/project/commerce"
}
},
{
"name": "drupal/config_filter",
"version": "2.3.0",
......
name: Ajax form Cart
description: create the ajax
package: Custom
type: module
core_version_requirement: ^8.8 || ^9
modal.form.js:
js:
js/modal_form.js: {}
dependencies:
- core/drupal.dialog.ajax
- core/jquery
- core/jquery.once
<?php
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\InvokeCommand;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_form_alter().
*/
function ajax_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
foreach ($form["#attributes"]["class"] as $id){
if ($id == 'commerce-order-item-add-to-cart-form'){
$form['actions']['submit']['#ajax'] = [
'callback' => 'ajax_callback',
'event' =>'click',
];
$form['#attached']['library'][] = 'ajax/modal.form.js';
}
}
}
function ajax_callback(array &$form, FormStateInterface $form_state){
$ajax_response = new AjaxResponse();
$ajax_response->addCommand(new InvokeCommand(NULL, 'myTest', ['some Var']));
return $ajax_response;
}
(function($) {
$.fn.myTest = function() {
var totalarray = [];
var request = new XMLHttpRequest();
request.open("GET", "http://store.loc/cart?_format=json");
request.send();
request.onload = function (){
let test = JSON.parse(request.response);
test.forEach( // перебираем все элементы массива array
function sumNumber( currentValue ) {
console.log(currentValue);
// total.push(currentValue.total_price.formatted);
currentValue.order_items.forEach( // перебираем все элементы массива array
function Items( currentItem ) {
totalarray.push(currentItem.title+"<br>"+currentItem.quantity+"<br>"+currentValue.total_price.formatted+"<br>");
//title1.push(currentItem.title);
//quantity.push(currentItem.quantity);
// присваивает
}
);
// title2 = title1.toString();
}
);
var frontpageModal = Drupal.dialog("<div>"+totalarray+"</div>",{
title: 'Modal on frontpage',
dialogClass: 'front-modal',
width: 400,
height: 400,
autoResize: true,
close: function (event) {
// Удаляем элемент который использовался для содержимого.
jquery(event.target).remove();
}
});
// Отображает модальное окно с overlay.
frontpageModal.showModal();
// Вы также можете использовать
// frontpageModal.show();
// чтобы отобразить модальное окно без overlay, и все элементы за
// модальным окном останутся активными.
}
};
})(jQuery);
/*(function ($, Drupal, drupalSettings) {
Drupal.behaviors.block = {
attach: function (context, settings) {
jQuery(document, context).once('block').each( function() {
var totalarray = [];
var title1 = [];
var quantity =[];
var total =[];
var title2 ='';
var request = new XMLHttpRequest();
request.open("GET", "http://store.loc/cart?_format=json");
request.send();
request.onload = function (){
let test = JSON.parse(request.response);
test.forEach( // перебираем все элементы массива array
function sumNumber( currentValue ) {
console.log(currentValue);
total.push(currentValue.total_price.formatted);
currentValue.order_items.forEach( // перебираем все элементы массива array
function Items( currentItem ) {
totalarray.push(currentItem.title+"<br>"+currentItem.quantity+"<br>"+currentValue.total_price.formatted+"<br>");
//title1.push(currentItem.title);
//quantity.push(currentItem.quantity);
// присваивает
}
);
title2 = title1.toString();
}
);
var frontpageModal = Drupal.dialog("<div>"+totalarray+"</div>",{
title: 'Modal on frontpage',
dialogClass: 'front-modal',
width: 400,
height: 400,
autoResize: true,
close: function (event) {
// Удаляем элемент который использовался для содержимого.
jquery(event.target).remove();
}
});
// Отображает модальное окно с overlay.
frontpageModal.showModal();
// Вы также можете использовать
// frontpageModal.show();
// чтобы отобразить модальное окно без overlay, и все элементы за
// модальным окном останутся активными.
}
});
}
}
} (jQuery, Drupal, drupalSettings));*/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment