Changeset 2753758
- Timestamp:
- 07/08/2022 01:12:20 PM (4 years ago)
- Location:
- datacake-core
- Files:
-
- 1 deleted
- 26 edited
- 1 copied
-
tags/1.2.8 (deleted)
-
tags/1.2.9 (copied) (copied from datacake-core/trunk)
-
tags/1.2.9/README.md (modified) (1 diff)
-
tags/1.2.9/README.txt (modified) (2 diffs)
-
tags/1.2.9/datacake_core.php (modified) (2 diffs)
-
tags/1.2.9/src/Admin/ApiViews/AbstractApiView.php (modified) (1 diff)
-
tags/1.2.9/src/Admin/ApiViews/ChannelApiView.php (modified) (3 diffs)
-
tags/1.2.9/src/Admin/ApiViews/ChannelGroupApiView.php (modified) (2 diffs)
-
tags/1.2.9/src/Admin/ApiViews/ChannelTypeApiView.php (modified) (1 diff)
-
tags/1.2.9/src/Admin/ApiViews/CityApiView.php (modified) (2 diffs)
-
tags/1.2.9/src/Admin/ApiViews/ProductApiView.php (modified) (4 diffs)
-
tags/1.2.9/src/Admin/ApiViews/ProductCategoryApiView.php (modified) (1 diff)
-
tags/1.2.9/src/Admin/ApiViews/ProductTagApiView.php (modified) (1 diff)
-
tags/1.2.9/src/Admin/js/datacake_core-admin.js (modified) (2 diffs)
-
tags/1.2.9/src/Shortcodes/CityShortcode.php (modified) (6 diffs)
-
trunk/README.md (modified) (1 diff)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/datacake_core.php (modified) (2 diffs)
-
trunk/src/Admin/ApiViews/AbstractApiView.php (modified) (1 diff)
-
trunk/src/Admin/ApiViews/ChannelApiView.php (modified) (3 diffs)
-
trunk/src/Admin/ApiViews/ChannelGroupApiView.php (modified) (2 diffs)
-
trunk/src/Admin/ApiViews/ChannelTypeApiView.php (modified) (1 diff)
-
trunk/src/Admin/ApiViews/CityApiView.php (modified) (2 diffs)
-
trunk/src/Admin/ApiViews/ProductApiView.php (modified) (4 diffs)
-
trunk/src/Admin/ApiViews/ProductCategoryApiView.php (modified) (1 diff)
-
trunk/src/Admin/ApiViews/ProductTagApiView.php (modified) (1 diff)
-
trunk/src/Admin/js/datacake_core-admin.js (modified) (2 diffs)
-
trunk/src/Shortcodes/CityShortcode.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
datacake-core/tags/1.2.9/README.md
r2708122 r2753758 8 8 * This is a Wordpress plugin, for Datacake clients and other customers who would like the functionalities 9 9 Based on the City you can create page redirects to show the correct page 10 - shortcodes: 11 dk_city_cobertura 10 shortcodes: <--- Vai criar o formulario de cobertura 11 dk_city_cobertura 12 Atributes of the shortcode: 13 'success' => '😊🎉✔<br>Temos cobertura em sua cidade', 14 'error' => 'Infelizmente sua cidade não tem cobertura ainda.<br>Qualquer dúvida entre em contato.', 15 'assine_url' => '/assine' 12 16 dk_city_list <--- This will create a list of all the cities on the system 17 Atributes of the shortcode: 18 'list_class' => 'g-cols via_flex valign_top type_default', 19 'list_item_class' => 'vc_col-sm-{{col}} wpb_column vc_column_container', 20 'col' => 3, 21 'include_neighborhood' => false, 13 22 dk_city_select <--- This will create a select with a button to save the cookie 23 Atributes of the shortcode: 24 'display_field' => 'name', 25 'group_class' => 'form-group', 26 'group_id' => 'choosecity-formgroup', 27 'name' => 'in-cities', 28 'select-class' => 'form-control', 29 'btn_id' => 'chooseCitySubmit', 30 'btn_class' => 'btn btn-outline-primary text-white', 31 'btn_text' => 'Continuar', 32 'ignore_neighborhood' => false, 33 'auto_select' => false 14 34 dk_city_pin <--- This will create a pin with information of the selected city 35 Atributes of the shortcode 36 'class' => 'pin-city', 37 'class-marker' => 'fa fa-map-marker', 38 'class-dropdown' => 'fa fa-chevron-down' 15 39 - widgets: 16 40 City SEO, this will replicate a text changing the city in the text for SEO purposes 17 18 * Version: V1.2.8 41 * Version: V1.2.9 19 42 20 43 -
datacake-core/tags/1.2.9/README.txt
r2708122 r2753758 6 6 Tested up to: 5.9.2 7 7 Requires PHP: 7.2 8 Stable tag: 1.2. 89 Last Tag: 1.2. 78 Stable tag: 1.2.9 9 Last Tag: 1.2.8 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 41 41 'btn_text' => 'Continuar', 42 42 'ignore_neighborhood' => false, 43 'auto_select' => false 43 44 dk_city_pin <--- This will create a pin with information of the selected city 44 45 Atributes of the shortcode -
datacake-core/tags/1.2.9/datacake_core.php
r2708122 r2753758 16 16 * Plugin URI: http://www.datacake.com.br 17 17 * Description: Plugin Datacake para linkar com as Funcionalidade do Data ISP/ISP OG - Redirecionar cidade baseada no cookie 18 * Version: 1.2. 818 * Version: 1.2.9 19 19 * Author: Paulo Peres Jr 20 20 * Author URI: https://github.com/PauloPeres … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'DATACAKE_CORE_VERSION', '1.2. 8' );38 define( 'DATACAKE_CORE_VERSION', '1.2.9' ); 39 39 40 40 require_once __DIR__ . '/vendor/autoload.php'; -
datacake-core/tags/1.2.9/src/Admin/ApiViews/AbstractApiView.php
r2698991 r2753758 8 8 public $api; 9 9 public $extraActions = []; 10 11 public function create_or_get_term_id($name,$taxonomy,$parent_id=0,$slug=null){ 12 $term = term_exists( $name, $taxonomy ); 13 if(!$slug){ 14 $slug = "dk_".sanitize_title($name); 15 } 16 $data = [ 17 'description' => $name, 18 'slug' => $slug, 19 'parent' => $parent_id, 20 ]; 21 22 if($term){ 23 $term = wp_update_term($term['term_id'], $taxonomy ,$data); 24 }else{ 25 $term = wp_insert_term($name, $taxonomy ,$data); 26 } 27 return $term['term_id']; 28 } 29 public function get_current_terms($id,$taxonomy, $skip_dk = true){ 30 if($id){ 31 $cur_terms = get_the_terms($id, $taxonomy); 32 if($cur_terms){ 33 $ids = []; 34 foreach ($cur_terms as $key => $term) { 35 if(!str_contains($term->slug, "dk_")){ 36 $ids[] = $term->term_id; 37 } 38 39 } 40 return $ids; 41 } 42 } 43 return []; 44 } 10 45 11 46 function register_actions($loader){ -
datacake-core/tags/1.2.9/src/Admin/ApiViews/ChannelApiView.php
r2698991 r2753758 82 82 } 83 83 } 84 85 $tags = $this->get_terms_tags_ids($doc->relationship('types') );84 $post_id = $post ? $post->ID : null; 85 $tags = $this->get_terms_tags_ids($doc->relationship('types'),$post_id); 86 86 $cats = array_merge( 87 $this->get_category_ids($doc->relationship('groups') ),88 $this->get_plan_category($doc->relationship('products') )87 $this->get_category_ids($doc->relationship('groups'),$post_id), 88 $this->get_plan_category($doc->relationship('products'),$post_id) 89 89 ); 90 90 … … 149 149 } 150 150 151 private function get_terms_tags_ids($documents){ 152 153 $ids = []; 151 152 153 private function get_terms_tags_ids($documents,$id){ 154 155 $ids = $this->get_current_terms($id,'isp_canais_tag'); 156 154 157 foreach ($documents->resources() as $key => $doc) { 155 $term = term_exists( $doc->attribute('name'), 'isp_canais_tag' );156 if($term ){157 $ids[] = $ doc->attribute('name');158 $term_id = $this->create_or_get_term_id($doc->attribute('name'),'isp_canais_tag'); 159 if($term_id){ 160 $ids[] = $term_id; 158 161 } 159 162 } … … 161 164 return $ids; 162 165 } 163 private function get_category_ids($documents){ 164 $parent_term = term_exists( 'Grupos','isp_canais_category'); 165 $ids = []; 166 $ids[] = $parent_term['term_id']; 166 private function get_category_ids($documents,$id){ 167 $parent_id = $this->create_or_get_term_id( 'Grupos','isp_canais_category'); 168 169 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 170 $ids = $this->get_current_terms($id,'isp_canais_category'); 171 //$ids = []; 172 $ids[] = $parent_id; 167 173 foreach ($documents->resources() as $key => $doc) { 168 $term = term_exists( $doc->attribute('name'), 'isp_canais_category' ); 169 if($term){ 170 $ids[] = $term['term_id']; 174 $term_id = $this->create_or_get_term_id($doc->attribute('name'),'isp_canais_category',$parent_id); 175 176 if($term_id){ 177 $ids[] = $term_id; 171 178 } 172 179 } 173 180 return $ids; 174 181 } 175 private function create_or_get_parent_product_category(){ 176 $term = term_exists( 'Planos','isp_canais_category'); 177 if($term){ 178 return $term['term_id']; 179 } 180 $data = [ 181 'description' => 'Planos', 182 'slug' => 'planos', 183 'parent' => null, 184 ]; 185 186 $term_id = wp_insert_term('Planos','isp_canais_category',$data); 187 return $term_id; 188 189 } 190 private function create_or_get_term_id($doc,$parent_id){ 191 $term = term_exists( $doc->attribute('name'), 'isp_canais_category' ); 192 $data = [ 193 'description' => $doc->attribute('name'), 194 'slug' => $doc->attribute('sku'), 195 'parent' => $parent_id, 196 ]; 197 198 if($term){ 199 $term_id = wp_update_term($term['term_id'], 'isp_canais_category' ,$data); 200 }else{ 201 $term_id = wp_insert_term($doc->attribute('name'), 'isp_canais_category' ,$data); 202 } 203 return $term['term_id']; 204 } 205 private function get_plan_category($plans){ 206 $parent_id = $this->create_or_get_parent_product_category(); 207 $ids = []; 182 183 184 private function get_plan_category($plans,$id){ 185 $parent_id = $this->create_or_get_term_id( 'Planos','isp_canais_category'); 186 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 187 $ids = $this->get_current_terms($id,'isp_canais_category'); 188 //$ids = []; 208 189 $ids[] = $parent_id; 209 190 foreach ($plans->resources() as $key => $doc) { 210 $term_id = $this->create_or_get_term_id($doc ,$parent_id);191 $term_id = $this->create_or_get_term_id($doc->attribute('name'),'isp_canais_category',$parent_id,"dk_".$doc->attribute('sku')); 211 192 if($term_id){ 212 193 $ids[] = $term_id; -
datacake-core/tags/1.2.9/src/Admin/ApiViews/ChannelGroupApiView.php
r2698991 r2753758 14 14 ]; 15 15 } 16 private function create_or_get_parent_group_category(){ 17 $term = term_exists( 'Grupos', $this->taxonomy); 18 if($term){ 19 return $term['term_id']; 20 } 21 $data = [ 22 'description' => 'Grupos', 23 'slug' => 'grupos', 24 'parent' => null, 25 ]; 26 27 $term_id = wp_insert_term('Grupos', $this->taxonomy, $data); 28 return $term_id; 29 30 } 16 31 17 function sync(){ 32 18 … … 51 37 if($response->isSuccessful()){ 52 38 if($response->hasDocument()){ 53 $parent_id = $this->create_or_get_parent_group_category(); 39 $parent_id = $this->create_or_get_term_id( 'Grupos',$this->taxonomy ); 40 54 41 foreach ($response->document()->primaryResources() as $key => $doc) { 55 $term = term_exists( $doc->attribute('name'), $this->taxonomy ); 56 $data = [ 57 'description' => $doc->attribute('name'), 58 'slug' => $doc->attribute('name'), 59 'parent' => $parent_id, 60 ]; 61 62 if($term){ 63 $term_id = wp_update_term($term['term_id'],$this->taxonomy,$data); 64 }else{ 65 $term_id = wp_insert_term($doc->attribute('name'),$this->taxonomy,$data); 66 } 42 $term_id = $this->create_or_get_term_id( $doc->attribute('name'),$this->taxonomy,$parent_id ); 67 43 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 68 69 44 } 70 45 }else{ -
datacake-core/tags/1.2.9/src/Admin/ApiViews/ChannelTypeApiView.php
r2698991 r2753758 36 36 if($response->hasDocument()){ 37 37 foreach ($response->document()->primaryResources() as $key => $doc) { 38 $term = term_exists( $doc->attribute('name'), $this->taxonomy ); 39 40 $data = [ 41 'slug' => $doc->id(), 42 'parent' => null, 43 ]; 44 45 if($term){ 46 $term_id = wp_update_term($term['term_id'], $this->taxonomy, $data); 47 }else{ 48 $term_id = wp_insert_term($doc->attribute('name'),$this->taxonomy,$data); 49 } 38 $term_id = $this->create_or_get_term_id( $doc->attribute('name'),$this->taxonomy ); 50 39 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 51 40 } -
datacake-core/tags/1.2.9/src/Admin/ApiViews/CityApiView.php
r2698991 r2753758 4 4 use Datacake\Core\Admin\ApiViews\AbstractApiView; 5 5 use Datacake\Core\Wda\CityApi; 6 use Datacake\Core\Models\IspCity; 6 7 7 8 class CityApiView extends AbstractApiView { … … 9 10 $this->path = "isp_city_view"; 10 11 $this->api = new CityApi(); 12 $this->extraActions = [ 13 "sync" 14 ]; 15 $this->cityApi = new CityApi(); 16 } 17 public function sync(){ 18 19 $message = [ 20 "status"=>"error", 21 "mensagem" => "starting" 22 ]; 23 $q = $this->api; 24 $page = ["number" => 1, "size" => 15]; 25 if(isset($_POST['page'])){ 26 $page["number"] = sanitize_key($_POST['page']); 27 } 28 29 $q = $q->setJsonApiPage($page); 30 $q = $q->setJsonApiFields([ 31 'created','updated','name','short_name', 32 'id','code','lat','long', 33 'redirect_url','is_neighborhood','neighborhood_name','products','products.id' 34 ]); 35 $q = $q->setJsonApiInclude([ 36 'products' 37 ]); 38 39 //'product_type', 40 //'addons' 41 //'options' 42 //'categories' 43 //'inventory' 44 //'tags', 45 $response = $q->list(); 46 47 if($response->isSuccessful()){ 48 if($response->hasDocument()){ 49 50 foreach ($response->document()->primaryResources() as $key => $doc) { 51 $entity = IspCity::where('remote_id',$doc->id())->first(); 52 53 $data = [ 54 'name'=>$doc->attribute('name'), 55 'short_name'=>$doc->attribute('short_name'), 56 'code'=>$doc->attribute('code')?$doc->attribute('code'):$doc->attribute('name'), 57 'lat'=>$doc->attribute('lat'), 58 'long'=>$doc->attribute('long'), 59 'remote_id'=>$doc->id(), 60 'redirect_url'=>$doc->attribute('redirect_url'), 61 'is_neighborhood'=>$doc->attribute('is_neighborhood'), 62 'neighborhood_name'=>$doc->attribute('neighborhood_name'), 63 ]; 64 if($entity){ 65 $entity->update($data); 66 }else{ 67 $entity = new IspCity(); 68 $entity->create($data); 69 } 70 $this->addCityCategoryToProducts($doc->relationship('products'),$doc); 71 72 73 } 74 75 76 77 }else{ 78 $message = [ 79 "status"=>"success", 80 "mensagem" => "Sem Cidades" 81 ]; 82 } 83 }else{ 84 // TODO GET ERROR FROM API 85 $message = [ 86 "status"=>"error", 87 "mensagem" => "Error from API" 88 ]; 89 } 90 $meta = $response->document()->meta(); 91 if($meta['pagination']['page'] < $meta['pagination']['pages']){ 92 $message = [ 93 "status"=>"success", 94 "mensagem" => "Sincronização de cidades pagina:".$meta['pagination']['page']." de ".$meta['pagination']['pages']." concluida", 95 "next_page" => $meta['pagination']['page'] + 1, 96 "pagination" => $meta['pagination'] 97 ]; 98 } else { 99 $message = [ 100 "status"=>"success", 101 "mensagem" => "Sincronização de cidades concluida", 102 "next_page" => null 103 ]; 104 } 105 106 if($message['status'] == "error"){ 107 return wp_send_json_error($message); 108 } 109 return wp_send_json_success($message); 110 11 111 } 12 112 113 function getPost($id){ 114 $posts = query_posts( 115 array( 116 'post_per_page' => 1, 117 'post_type' => "isp_planos", 118 'meta_query' => array( 119 array( 120 'key' => 'isp_remote_id', 121 'value' => $id, 122 ) 123 ), 124 ) 125 ); 126 $post = null; 127 128 if($posts && count($posts) >= 1 ){ 129 $post = $posts[0]; 130 } 131 return $post; 132 } 133 134 function addCityCategoryToProducts($documents,$city){ 135 $parent_id = $this->create_or_get_term_id( 'Cidades','isp_planos_category'); 136 foreach ($documents->resources() as $key => $doc) { 137 $post = $this->getPost($doc->id()); 138 $ids = $this->get_current_terms($post->ID,'isp_planos_category'); 139 $ids[] = $parent_id; 140 $term_id = $this->create_or_get_term_id( $city->attribute('name'), 'isp_planos_category' ,$parent_id); 141 $ids[] = $term_id; 142 wp_set_object_terms($post->ID,$ids,'isp_planos_category',true); 143 144 145 } 146 147 } 13 148 } 14 149 -
datacake-core/tags/1.2.9/src/Admin/ApiViews/ProductApiView.php
r2698991 r2753758 118 118 } 119 119 } 120 $tags = $this->get_terms_tags_ids($doc->relationship('tags')); 121 $cats = $this->get_category_ids($doc->relationship('categories')); 120 $post_id = $post ? $post->ID : null; 121 $tags = $this->get_terms_tags_ids($doc->relationship('tags'),$post_id); 122 $cats = $this->get_category_ids($doc->relationship('categories'),$post_id); 123 /* 124 125 $cats = array_merge( 126 $this->get_category_ids($doc->relationship('categories'),$post_id), 127 $this->get_cidade_category($doc->relationship('products'),$post_id) 128 ); 129 */ 130 122 131 $data = [ 123 132 'post_type' => $this->taxonomy, … … 133 142 'meta_input' => $meta //(array) Array of post meta values keyed by their post meta key. Default empty. 134 143 ]; 135 136 144 if($post){ 137 145 $data['ID'] = $post->ID; … … 178 186 179 187 } 180 181 private function get_terms_tags_ids($documents){ 182 183 $ids = []; 188 189 private function get_terms_tags_ids($documents,$id){ 190 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 191 $ids = $this->get_current_terms($id,'isp_planos_tag'); 192 //$ids = []; 184 193 foreach ($documents->resources() as $key => $doc) { 185 194 $term = term_exists( $doc->attribute('value'), 'isp_planos_tag' ); … … 191 200 return $ids; 192 201 } 193 private function get_category_ids($documents){ 194 195 $ids = []; 202 203 204 205 206 private function get_category_ids($documents,$id){ 207 $parent_id = $this->create_or_get_term_id( 'Categorias','isp_planos_category'); 208 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 209 $ids = $this->get_current_terms($id,'isp_planos_category'); 210 //$ids = []; 211 $ids[] = $parent_id; 196 212 foreach ($documents->resources() as $key => $doc) { 197 $term = term_exists( $doc->attribute('name'), 'isp_planos_category');198 if($term ){199 $ids[] = $term ['term_id'];213 $term_id = $this->create_or_get_term_id( $doc->attribute('name'), 'isp_planos_category' ,$parent_id); 214 if($term_id){ 215 $ids[] = $term_id; 200 216 } 201 217 } 202 218 return $ids; 203 219 } 220 private function get_cidade_category($cities,$id){ 221 $parent_id = $this->create_or_get_term_id( 'Cidades','isp_planos_category'); 222 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 223 $ids = $this->get_current_terms($id,'isp_planos_category'); 224 //$ids = []; 225 $ids[] = $parent_id; 226 foreach ($plans->resources() as $key => $doc) { 227 $term_id = $this->create_or_get_term_id( $doc->attribute('name'), 'isp_planos_category' ,$parent_id); 228 if($term_id){ 229 $ids[] = $term_id; 230 } 231 } 232 return $ids; 233 } 204 234 205 235 -
datacake-core/tags/1.2.9/src/Admin/ApiViews/ProductCategoryApiView.php
r2698991 r2753758 38 38 if($response->isSuccessful()){ 39 39 if($response->hasDocument()){ 40 $parent_id = $this->create_or_get_term_id( 'Categorias',$this->taxonomy); 40 41 foreach ($response->document()->primaryResources() as $key => $doc) { 41 $term = term_exists( $doc->attribute('name'), $this->taxonomy ); 42 $data = [ 43 'description' => $doc->attribute('description'), 44 'slug' => $doc->attribute('slug'), 45 'parent' => null, 46 ]; 47 48 if($term){ 49 $term_id = wp_update_term($term['term_id'],$this->taxonomy,$data); 50 }else{ 51 $term_id = wp_insert_term($doc->attribute('name'),$this->taxonomy,$data); 52 } 42 $term_id = $this->create_or_get_term_id( $doc->attribute('name'),$this->taxonomy,$parent_id ); 53 43 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 54 44 } -
datacake-core/tags/1.2.9/src/Admin/ApiViews/ProductTagApiView.php
r2698991 r2753758 37 37 if($response->hasDocument()){ 38 38 foreach ($response->document()->primaryResources() as $key => $doc) { 39 $term = term_exists( $doc->attribute('value'), $this->taxonomy ); 40 41 $data = [ 42 'slug' => $doc->id(), 43 'parent' => null, 44 ]; 45 46 if($term){ 47 $term_id = wp_update_term($term['term_id'], $this->taxonomy, $data); 48 }else{ 49 $term_id = wp_insert_term($doc->attribute('value'),$this->taxonomy,$data); 50 } 39 $term_id = $this->create_or_get_term_id( $doc->attribute('value'),$this->taxonomy ); 51 40 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 52 41 } -
datacake-core/tags/1.2.9/src/Admin/js/datacake_core-admin.js
r2698960 r2753758 45 45 cleanMessage(); 46 46 disableBtn("#dk_core_sync_products"); 47 updateMessage("Começando aguarde ..."); 47 updateMessage("Passo 1 de 4 - Começando sincronização de categorias ..."); 48 48 49 49 50 // Passo 1 Baixando Categorias 50 51 recursive_sync("isp_product_category_view-sync",function(){ 51 52 // Passo 1 Baixando Tags 53 updateMessage("Passo 2 de 4 - Começando sincronização de tags de produtos ..."); 52 54 recursive_sync("isp_product_tag_view-sync",function(){ 53 55 // Baixando Produtos 56 updateMessage("Passo 3 de 4 - Começando sincronização de produtos ..."); 54 57 recursive_sync("isp_product_view-sync",function(){ 55 enableBtn("#dk_core_sync_products"); 56 updateMessage("Sincronização Concluida"); 58 updateMessage("Passo 4 de 4 - Começando sincronização de cidades ..."); 59 recursive_sync("isp_city_view-sync",function(){ 60 enableBtn("#dk_core_sync_products"); 61 updateMessage("Sincronização Concluida 🥳"); 62 }); 57 63 }); 58 64 }); … … 94 100 cleanMessage("canais"); 95 101 //disableBtn("#dk_core_sync_canais"); 96 updateMessage(" Começando aguarde...", "canais");102 updateMessage("Passo 1 de 3 - Começando sincronização de categorias/grupos de canais ...", "canais"); 97 103 98 104 // Passo 1 Baixando Categorias 99 105 recursive_sync("isp_channel_group_view-sync",function(){ 100 106 // Passo 1 Baixando Tags 107 updateMessage("Passo 2 de 3 - Começando sincronização de tags/tipos de canais ...", "canais"); 101 108 recursive_sync("isp_channel_type_view-sync",function(){ 102 109 // Baixando Produtos 110 updateMessage("Passo 3 de 3 - Começando sincronização de canais ...", "canais"); 103 111 recursive_sync("isp_channel_view-sync",function(){ 104 112 enableBtn("#dk_core_sync_products"); 105 updateMessage("Sincronização Concluida", "canais");113 updateMessage("Sincronização concluida 🥳", "canais"); 106 114 },"canais"); 107 115 },"canais"); -
datacake-core/tags/1.2.9/src/Shortcodes/CityShortcode.php
r2698960 r2753758 55 55 'btn_text' => 'Continuar', 56 56 'ignore_neighborhood' => false, 57 'auto_select'=>false, 57 58 ), $attrs); 58 59 $referer = isset($_GET['redirect'])?$_GET['redirect']:get_home_url(); … … 62 63 $query = $query->where('is_neighborhood',false); 63 64 } 64 65 $auto_select = $opt['auto_select']; 65 66 $cities = $query->get(); 66 67 … … 69 70 //$html .= '<form action="/home">'; 70 71 $html .= '<div class id="'.$opt['group_id'].'" class="'.$opt['group_class'].'" >'; 71 $html .= '<select name="' . $opt['name'] . '" class="form-control" id="'.$opt['name'].'" aria-required="true" aria-invalid="false" >';72 $html .= '<select name="' . $opt['name'] . '" class="form-control" id="'.$opt['name'].'" aria-required="true" aria-invalid="false" onchange="detect_city_select_change(this)">'; 72 73 $html .= "<option value=''>Selecione uma cidade</option>"; 73 74 $cityCookie = false; … … 78 79 } 79 80 $html .= "</select>"; 80 $html .= "<button onClick=\"send_to_page(event)\" type=\"submit\" id=\"".$opt['btn_id']."\" class=\"".$opt['btn_class']."\"> ".$opt['btn_text']." </button>"; 81 if (!$auto_select) { 82 $html .= "<button onClick=\"send_to_page(event)\" type=\"submit\" id=\"".$opt['btn_id']."\" class=\"".$opt['btn_class']."\"> ".$opt['btn_text']." </button>"; 83 } 81 84 $html .= "</div>"; 82 85 //$html .= "</form><!---->"; … … 85 88 <script> 86 89 function send_to_page(event){ 87 event.preventDefault(); 90 if(event.preventDefault){ 91 event.preventDefault(); 92 } 88 93 var e = document.getElementById(\"".$opt['name']."\"); 89 94 var cityId = e.value; … … 106 111 },1000); 107 112 113 } 114 } 115 function detect_city_select_change(event){ 116 var auto_select = new Boolean($auto_select); 117 if(auto_select){ 118 send_to_page(event); 108 119 } 109 120 } -
datacake-core/trunk/README.md
r2708122 r2753758 8 8 * This is a Wordpress plugin, for Datacake clients and other customers who would like the functionalities 9 9 Based on the City you can create page redirects to show the correct page 10 - shortcodes: 11 dk_city_cobertura 10 shortcodes: <--- Vai criar o formulario de cobertura 11 dk_city_cobertura 12 Atributes of the shortcode: 13 'success' => '😊🎉✔<br>Temos cobertura em sua cidade', 14 'error' => 'Infelizmente sua cidade não tem cobertura ainda.<br>Qualquer dúvida entre em contato.', 15 'assine_url' => '/assine' 12 16 dk_city_list <--- This will create a list of all the cities on the system 17 Atributes of the shortcode: 18 'list_class' => 'g-cols via_flex valign_top type_default', 19 'list_item_class' => 'vc_col-sm-{{col}} wpb_column vc_column_container', 20 'col' => 3, 21 'include_neighborhood' => false, 13 22 dk_city_select <--- This will create a select with a button to save the cookie 23 Atributes of the shortcode: 24 'display_field' => 'name', 25 'group_class' => 'form-group', 26 'group_id' => 'choosecity-formgroup', 27 'name' => 'in-cities', 28 'select-class' => 'form-control', 29 'btn_id' => 'chooseCitySubmit', 30 'btn_class' => 'btn btn-outline-primary text-white', 31 'btn_text' => 'Continuar', 32 'ignore_neighborhood' => false, 33 'auto_select' => false 14 34 dk_city_pin <--- This will create a pin with information of the selected city 35 Atributes of the shortcode 36 'class' => 'pin-city', 37 'class-marker' => 'fa fa-map-marker', 38 'class-dropdown' => 'fa fa-chevron-down' 15 39 - widgets: 16 40 City SEO, this will replicate a text changing the city in the text for SEO purposes 17 18 * Version: V1.2.8 41 * Version: V1.2.9 19 42 20 43 -
datacake-core/trunk/README.txt
r2708122 r2753758 6 6 Tested up to: 5.9.2 7 7 Requires PHP: 7.2 8 Stable tag: 1.2. 89 Last Tag: 1.2. 78 Stable tag: 1.2.9 9 Last Tag: 1.2.8 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 41 41 'btn_text' => 'Continuar', 42 42 'ignore_neighborhood' => false, 43 'auto_select' => false 43 44 dk_city_pin <--- This will create a pin with information of the selected city 44 45 Atributes of the shortcode -
datacake-core/trunk/datacake_core.php
r2708122 r2753758 16 16 * Plugin URI: http://www.datacake.com.br 17 17 * Description: Plugin Datacake para linkar com as Funcionalidade do Data ISP/ISP OG - Redirecionar cidade baseada no cookie 18 * Version: 1.2. 818 * Version: 1.2.9 19 19 * Author: Paulo Peres Jr 20 20 * Author URI: https://github.com/PauloPeres … … 36 36 * Rename this for your plugin and update it as you release new versions. 37 37 */ 38 define( 'DATACAKE_CORE_VERSION', '1.2. 8' );38 define( 'DATACAKE_CORE_VERSION', '1.2.9' ); 39 39 40 40 require_once __DIR__ . '/vendor/autoload.php'; -
datacake-core/trunk/src/Admin/ApiViews/AbstractApiView.php
r2698991 r2753758 8 8 public $api; 9 9 public $extraActions = []; 10 11 public function create_or_get_term_id($name,$taxonomy,$parent_id=0,$slug=null){ 12 $term = term_exists( $name, $taxonomy ); 13 if(!$slug){ 14 $slug = "dk_".sanitize_title($name); 15 } 16 $data = [ 17 'description' => $name, 18 'slug' => $slug, 19 'parent' => $parent_id, 20 ]; 21 22 if($term){ 23 $term = wp_update_term($term['term_id'], $taxonomy ,$data); 24 }else{ 25 $term = wp_insert_term($name, $taxonomy ,$data); 26 } 27 return $term['term_id']; 28 } 29 public function get_current_terms($id,$taxonomy, $skip_dk = true){ 30 if($id){ 31 $cur_terms = get_the_terms($id, $taxonomy); 32 if($cur_terms){ 33 $ids = []; 34 foreach ($cur_terms as $key => $term) { 35 if(!str_contains($term->slug, "dk_")){ 36 $ids[] = $term->term_id; 37 } 38 39 } 40 return $ids; 41 } 42 } 43 return []; 44 } 10 45 11 46 function register_actions($loader){ -
datacake-core/trunk/src/Admin/ApiViews/ChannelApiView.php
r2698991 r2753758 82 82 } 83 83 } 84 85 $tags = $this->get_terms_tags_ids($doc->relationship('types') );84 $post_id = $post ? $post->ID : null; 85 $tags = $this->get_terms_tags_ids($doc->relationship('types'),$post_id); 86 86 $cats = array_merge( 87 $this->get_category_ids($doc->relationship('groups') ),88 $this->get_plan_category($doc->relationship('products') )87 $this->get_category_ids($doc->relationship('groups'),$post_id), 88 $this->get_plan_category($doc->relationship('products'),$post_id) 89 89 ); 90 90 … … 149 149 } 150 150 151 private function get_terms_tags_ids($documents){ 152 153 $ids = []; 151 152 153 private function get_terms_tags_ids($documents,$id){ 154 155 $ids = $this->get_current_terms($id,'isp_canais_tag'); 156 154 157 foreach ($documents->resources() as $key => $doc) { 155 $term = term_exists( $doc->attribute('name'), 'isp_canais_tag' );156 if($term ){157 $ids[] = $ doc->attribute('name');158 $term_id = $this->create_or_get_term_id($doc->attribute('name'),'isp_canais_tag'); 159 if($term_id){ 160 $ids[] = $term_id; 158 161 } 159 162 } … … 161 164 return $ids; 162 165 } 163 private function get_category_ids($documents){ 164 $parent_term = term_exists( 'Grupos','isp_canais_category'); 165 $ids = []; 166 $ids[] = $parent_term['term_id']; 166 private function get_category_ids($documents,$id){ 167 $parent_id = $this->create_or_get_term_id( 'Grupos','isp_canais_category'); 168 169 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 170 $ids = $this->get_current_terms($id,'isp_canais_category'); 171 //$ids = []; 172 $ids[] = $parent_id; 167 173 foreach ($documents->resources() as $key => $doc) { 168 $term = term_exists( $doc->attribute('name'), 'isp_canais_category' ); 169 if($term){ 170 $ids[] = $term['term_id']; 174 $term_id = $this->create_or_get_term_id($doc->attribute('name'),'isp_canais_category',$parent_id); 175 176 if($term_id){ 177 $ids[] = $term_id; 171 178 } 172 179 } 173 180 return $ids; 174 181 } 175 private function create_or_get_parent_product_category(){ 176 $term = term_exists( 'Planos','isp_canais_category'); 177 if($term){ 178 return $term['term_id']; 179 } 180 $data = [ 181 'description' => 'Planos', 182 'slug' => 'planos', 183 'parent' => null, 184 ]; 185 186 $term_id = wp_insert_term('Planos','isp_canais_category',$data); 187 return $term_id; 188 189 } 190 private function create_or_get_term_id($doc,$parent_id){ 191 $term = term_exists( $doc->attribute('name'), 'isp_canais_category' ); 192 $data = [ 193 'description' => $doc->attribute('name'), 194 'slug' => $doc->attribute('sku'), 195 'parent' => $parent_id, 196 ]; 197 198 if($term){ 199 $term_id = wp_update_term($term['term_id'], 'isp_canais_category' ,$data); 200 }else{ 201 $term_id = wp_insert_term($doc->attribute('name'), 'isp_canais_category' ,$data); 202 } 203 return $term['term_id']; 204 } 205 private function get_plan_category($plans){ 206 $parent_id = $this->create_or_get_parent_product_category(); 207 $ids = []; 182 183 184 private function get_plan_category($plans,$id){ 185 $parent_id = $this->create_or_get_term_id( 'Planos','isp_canais_category'); 186 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 187 $ids = $this->get_current_terms($id,'isp_canais_category'); 188 //$ids = []; 208 189 $ids[] = $parent_id; 209 190 foreach ($plans->resources() as $key => $doc) { 210 $term_id = $this->create_or_get_term_id($doc ,$parent_id);191 $term_id = $this->create_or_get_term_id($doc->attribute('name'),'isp_canais_category',$parent_id,"dk_".$doc->attribute('sku')); 211 192 if($term_id){ 212 193 $ids[] = $term_id; -
datacake-core/trunk/src/Admin/ApiViews/ChannelGroupApiView.php
r2698991 r2753758 14 14 ]; 15 15 } 16 private function create_or_get_parent_group_category(){ 17 $term = term_exists( 'Grupos', $this->taxonomy); 18 if($term){ 19 return $term['term_id']; 20 } 21 $data = [ 22 'description' => 'Grupos', 23 'slug' => 'grupos', 24 'parent' => null, 25 ]; 26 27 $term_id = wp_insert_term('Grupos', $this->taxonomy, $data); 28 return $term_id; 29 30 } 16 31 17 function sync(){ 32 18 … … 51 37 if($response->isSuccessful()){ 52 38 if($response->hasDocument()){ 53 $parent_id = $this->create_or_get_parent_group_category(); 39 $parent_id = $this->create_or_get_term_id( 'Grupos',$this->taxonomy ); 40 54 41 foreach ($response->document()->primaryResources() as $key => $doc) { 55 $term = term_exists( $doc->attribute('name'), $this->taxonomy ); 56 $data = [ 57 'description' => $doc->attribute('name'), 58 'slug' => $doc->attribute('name'), 59 'parent' => $parent_id, 60 ]; 61 62 if($term){ 63 $term_id = wp_update_term($term['term_id'],$this->taxonomy,$data); 64 }else{ 65 $term_id = wp_insert_term($doc->attribute('name'),$this->taxonomy,$data); 66 } 42 $term_id = $this->create_or_get_term_id( $doc->attribute('name'),$this->taxonomy,$parent_id ); 67 43 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 68 69 44 } 70 45 }else{ -
datacake-core/trunk/src/Admin/ApiViews/ChannelTypeApiView.php
r2698991 r2753758 36 36 if($response->hasDocument()){ 37 37 foreach ($response->document()->primaryResources() as $key => $doc) { 38 $term = term_exists( $doc->attribute('name'), $this->taxonomy ); 39 40 $data = [ 41 'slug' => $doc->id(), 42 'parent' => null, 43 ]; 44 45 if($term){ 46 $term_id = wp_update_term($term['term_id'], $this->taxonomy, $data); 47 }else{ 48 $term_id = wp_insert_term($doc->attribute('name'),$this->taxonomy,$data); 49 } 38 $term_id = $this->create_or_get_term_id( $doc->attribute('name'),$this->taxonomy ); 50 39 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 51 40 } -
datacake-core/trunk/src/Admin/ApiViews/CityApiView.php
r2698991 r2753758 4 4 use Datacake\Core\Admin\ApiViews\AbstractApiView; 5 5 use Datacake\Core\Wda\CityApi; 6 use Datacake\Core\Models\IspCity; 6 7 7 8 class CityApiView extends AbstractApiView { … … 9 10 $this->path = "isp_city_view"; 10 11 $this->api = new CityApi(); 12 $this->extraActions = [ 13 "sync" 14 ]; 15 $this->cityApi = new CityApi(); 16 } 17 public function sync(){ 18 19 $message = [ 20 "status"=>"error", 21 "mensagem" => "starting" 22 ]; 23 $q = $this->api; 24 $page = ["number" => 1, "size" => 15]; 25 if(isset($_POST['page'])){ 26 $page["number"] = sanitize_key($_POST['page']); 27 } 28 29 $q = $q->setJsonApiPage($page); 30 $q = $q->setJsonApiFields([ 31 'created','updated','name','short_name', 32 'id','code','lat','long', 33 'redirect_url','is_neighborhood','neighborhood_name','products','products.id' 34 ]); 35 $q = $q->setJsonApiInclude([ 36 'products' 37 ]); 38 39 //'product_type', 40 //'addons' 41 //'options' 42 //'categories' 43 //'inventory' 44 //'tags', 45 $response = $q->list(); 46 47 if($response->isSuccessful()){ 48 if($response->hasDocument()){ 49 50 foreach ($response->document()->primaryResources() as $key => $doc) { 51 $entity = IspCity::where('remote_id',$doc->id())->first(); 52 53 $data = [ 54 'name'=>$doc->attribute('name'), 55 'short_name'=>$doc->attribute('short_name'), 56 'code'=>$doc->attribute('code')?$doc->attribute('code'):$doc->attribute('name'), 57 'lat'=>$doc->attribute('lat'), 58 'long'=>$doc->attribute('long'), 59 'remote_id'=>$doc->id(), 60 'redirect_url'=>$doc->attribute('redirect_url'), 61 'is_neighborhood'=>$doc->attribute('is_neighborhood'), 62 'neighborhood_name'=>$doc->attribute('neighborhood_name'), 63 ]; 64 if($entity){ 65 $entity->update($data); 66 }else{ 67 $entity = new IspCity(); 68 $entity->create($data); 69 } 70 $this->addCityCategoryToProducts($doc->relationship('products'),$doc); 71 72 73 } 74 75 76 77 }else{ 78 $message = [ 79 "status"=>"success", 80 "mensagem" => "Sem Cidades" 81 ]; 82 } 83 }else{ 84 // TODO GET ERROR FROM API 85 $message = [ 86 "status"=>"error", 87 "mensagem" => "Error from API" 88 ]; 89 } 90 $meta = $response->document()->meta(); 91 if($meta['pagination']['page'] < $meta['pagination']['pages']){ 92 $message = [ 93 "status"=>"success", 94 "mensagem" => "Sincronização de cidades pagina:".$meta['pagination']['page']." de ".$meta['pagination']['pages']." concluida", 95 "next_page" => $meta['pagination']['page'] + 1, 96 "pagination" => $meta['pagination'] 97 ]; 98 } else { 99 $message = [ 100 "status"=>"success", 101 "mensagem" => "Sincronização de cidades concluida", 102 "next_page" => null 103 ]; 104 } 105 106 if($message['status'] == "error"){ 107 return wp_send_json_error($message); 108 } 109 return wp_send_json_success($message); 110 11 111 } 12 112 113 function getPost($id){ 114 $posts = query_posts( 115 array( 116 'post_per_page' => 1, 117 'post_type' => "isp_planos", 118 'meta_query' => array( 119 array( 120 'key' => 'isp_remote_id', 121 'value' => $id, 122 ) 123 ), 124 ) 125 ); 126 $post = null; 127 128 if($posts && count($posts) >= 1 ){ 129 $post = $posts[0]; 130 } 131 return $post; 132 } 133 134 function addCityCategoryToProducts($documents,$city){ 135 $parent_id = $this->create_or_get_term_id( 'Cidades','isp_planos_category'); 136 foreach ($documents->resources() as $key => $doc) { 137 $post = $this->getPost($doc->id()); 138 $ids = $this->get_current_terms($post->ID,'isp_planos_category'); 139 $ids[] = $parent_id; 140 $term_id = $this->create_or_get_term_id( $city->attribute('name'), 'isp_planos_category' ,$parent_id); 141 $ids[] = $term_id; 142 wp_set_object_terms($post->ID,$ids,'isp_planos_category',true); 143 144 145 } 146 147 } 13 148 } 14 149 -
datacake-core/trunk/src/Admin/ApiViews/ProductApiView.php
r2698991 r2753758 118 118 } 119 119 } 120 $tags = $this->get_terms_tags_ids($doc->relationship('tags')); 121 $cats = $this->get_category_ids($doc->relationship('categories')); 120 $post_id = $post ? $post->ID : null; 121 $tags = $this->get_terms_tags_ids($doc->relationship('tags'),$post_id); 122 $cats = $this->get_category_ids($doc->relationship('categories'),$post_id); 123 /* 124 125 $cats = array_merge( 126 $this->get_category_ids($doc->relationship('categories'),$post_id), 127 $this->get_cidade_category($doc->relationship('products'),$post_id) 128 ); 129 */ 130 122 131 $data = [ 123 132 'post_type' => $this->taxonomy, … … 133 142 'meta_input' => $meta //(array) Array of post meta values keyed by their post meta key. Default empty. 134 143 ]; 135 136 144 if($post){ 137 145 $data['ID'] = $post->ID; … … 178 186 179 187 } 180 181 private function get_terms_tags_ids($documents){ 182 183 $ids = []; 188 189 private function get_terms_tags_ids($documents,$id){ 190 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 191 $ids = $this->get_current_terms($id,'isp_planos_tag'); 192 //$ids = []; 184 193 foreach ($documents->resources() as $key => $doc) { 185 194 $term = term_exists( $doc->attribute('value'), 'isp_planos_tag' ); … … 191 200 return $ids; 192 201 } 193 private function get_category_ids($documents){ 194 195 $ids = []; 202 203 204 205 206 private function get_category_ids($documents,$id){ 207 $parent_id = $this->create_or_get_term_id( 'Categorias','isp_planos_category'); 208 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 209 $ids = $this->get_current_terms($id,'isp_planos_category'); 210 //$ids = []; 211 $ids[] = $parent_id; 196 212 foreach ($documents->resources() as $key => $doc) { 197 $term = term_exists( $doc->attribute('name'), 'isp_planos_category');198 if($term ){199 $ids[] = $term ['term_id'];213 $term_id = $this->create_or_get_term_id( $doc->attribute('name'), 'isp_planos_category' ,$parent_id); 214 if($term_id){ 215 $ids[] = $term_id; 200 216 } 201 217 } 202 218 return $ids; 203 219 } 220 private function get_cidade_category($cities,$id){ 221 $parent_id = $this->create_or_get_term_id( 'Cidades','isp_planos_category'); 222 // Não adianta pegar as tags e categorias que estão no produto por que se não na hora que uma tag for removido do wda não vai ser removida daqui 223 $ids = $this->get_current_terms($id,'isp_planos_category'); 224 //$ids = []; 225 $ids[] = $parent_id; 226 foreach ($plans->resources() as $key => $doc) { 227 $term_id = $this->create_or_get_term_id( $doc->attribute('name'), 'isp_planos_category' ,$parent_id); 228 if($term_id){ 229 $ids[] = $term_id; 230 } 231 } 232 return $ids; 233 } 204 234 205 235 -
datacake-core/trunk/src/Admin/ApiViews/ProductCategoryApiView.php
r2698991 r2753758 38 38 if($response->isSuccessful()){ 39 39 if($response->hasDocument()){ 40 $parent_id = $this->create_or_get_term_id( 'Categorias',$this->taxonomy); 40 41 foreach ($response->document()->primaryResources() as $key => $doc) { 41 $term = term_exists( $doc->attribute('name'), $this->taxonomy ); 42 $data = [ 43 'description' => $doc->attribute('description'), 44 'slug' => $doc->attribute('slug'), 45 'parent' => null, 46 ]; 47 48 if($term){ 49 $term_id = wp_update_term($term['term_id'],$this->taxonomy,$data); 50 }else{ 51 $term_id = wp_insert_term($doc->attribute('name'),$this->taxonomy,$data); 52 } 42 $term_id = $this->create_or_get_term_id( $doc->attribute('name'),$this->taxonomy,$parent_id ); 53 43 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 54 44 } -
datacake-core/trunk/src/Admin/ApiViews/ProductTagApiView.php
r2698991 r2753758 37 37 if($response->hasDocument()){ 38 38 foreach ($response->document()->primaryResources() as $key => $doc) { 39 $term = term_exists( $doc->attribute('value'), $this->taxonomy ); 40 41 $data = [ 42 'slug' => $doc->id(), 43 'parent' => null, 44 ]; 45 46 if($term){ 47 $term_id = wp_update_term($term['term_id'], $this->taxonomy, $data); 48 }else{ 49 $term_id = wp_insert_term($doc->attribute('value'),$this->taxonomy,$data); 50 } 39 $term_id = $this->create_or_get_term_id( $doc->attribute('value'),$this->taxonomy ); 51 40 update_term_meta( $term_id, 'wda_remote_id', $doc->id() ); 52 41 } -
datacake-core/trunk/src/Admin/js/datacake_core-admin.js
r2698960 r2753758 45 45 cleanMessage(); 46 46 disableBtn("#dk_core_sync_products"); 47 updateMessage("Começando aguarde ..."); 47 updateMessage("Passo 1 de 4 - Começando sincronização de categorias ..."); 48 48 49 49 50 // Passo 1 Baixando Categorias 50 51 recursive_sync("isp_product_category_view-sync",function(){ 51 52 // Passo 1 Baixando Tags 53 updateMessage("Passo 2 de 4 - Começando sincronização de tags de produtos ..."); 52 54 recursive_sync("isp_product_tag_view-sync",function(){ 53 55 // Baixando Produtos 56 updateMessage("Passo 3 de 4 - Começando sincronização de produtos ..."); 54 57 recursive_sync("isp_product_view-sync",function(){ 55 enableBtn("#dk_core_sync_products"); 56 updateMessage("Sincronização Concluida"); 58 updateMessage("Passo 4 de 4 - Começando sincronização de cidades ..."); 59 recursive_sync("isp_city_view-sync",function(){ 60 enableBtn("#dk_core_sync_products"); 61 updateMessage("Sincronização Concluida 🥳"); 62 }); 57 63 }); 58 64 }); … … 94 100 cleanMessage("canais"); 95 101 //disableBtn("#dk_core_sync_canais"); 96 updateMessage(" Começando aguarde...", "canais");102 updateMessage("Passo 1 de 3 - Começando sincronização de categorias/grupos de canais ...", "canais"); 97 103 98 104 // Passo 1 Baixando Categorias 99 105 recursive_sync("isp_channel_group_view-sync",function(){ 100 106 // Passo 1 Baixando Tags 107 updateMessage("Passo 2 de 3 - Começando sincronização de tags/tipos de canais ...", "canais"); 101 108 recursive_sync("isp_channel_type_view-sync",function(){ 102 109 // Baixando Produtos 110 updateMessage("Passo 3 de 3 - Começando sincronização de canais ...", "canais"); 103 111 recursive_sync("isp_channel_view-sync",function(){ 104 112 enableBtn("#dk_core_sync_products"); 105 updateMessage("Sincronização Concluida", "canais");113 updateMessage("Sincronização concluida 🥳", "canais"); 106 114 },"canais"); 107 115 },"canais"); -
datacake-core/trunk/src/Shortcodes/CityShortcode.php
r2698960 r2753758 55 55 'btn_text' => 'Continuar', 56 56 'ignore_neighborhood' => false, 57 'auto_select'=>false, 57 58 ), $attrs); 58 59 $referer = isset($_GET['redirect'])?$_GET['redirect']:get_home_url(); … … 62 63 $query = $query->where('is_neighborhood',false); 63 64 } 64 65 $auto_select = $opt['auto_select']; 65 66 $cities = $query->get(); 66 67 … … 69 70 //$html .= '<form action="/home">'; 70 71 $html .= '<div class id="'.$opt['group_id'].'" class="'.$opt['group_class'].'" >'; 71 $html .= '<select name="' . $opt['name'] . '" class="form-control" id="'.$opt['name'].'" aria-required="true" aria-invalid="false" >';72 $html .= '<select name="' . $opt['name'] . '" class="form-control" id="'.$opt['name'].'" aria-required="true" aria-invalid="false" onchange="detect_city_select_change(this)">'; 72 73 $html .= "<option value=''>Selecione uma cidade</option>"; 73 74 $cityCookie = false; … … 78 79 } 79 80 $html .= "</select>"; 80 $html .= "<button onClick=\"send_to_page(event)\" type=\"submit\" id=\"".$opt['btn_id']."\" class=\"".$opt['btn_class']."\"> ".$opt['btn_text']." </button>"; 81 if (!$auto_select) { 82 $html .= "<button onClick=\"send_to_page(event)\" type=\"submit\" id=\"".$opt['btn_id']."\" class=\"".$opt['btn_class']."\"> ".$opt['btn_text']." </button>"; 83 } 81 84 $html .= "</div>"; 82 85 //$html .= "</form><!---->"; … … 85 88 <script> 86 89 function send_to_page(event){ 87 event.preventDefault(); 90 if(event.preventDefault){ 91 event.preventDefault(); 92 } 88 93 var e = document.getElementById(\"".$opt['name']."\"); 89 94 var cityId = e.value; … … 106 111 },1000); 107 112 113 } 114 } 115 function detect_city_select_change(event){ 116 var auto_select = new Boolean($auto_select); 117 if(auto_select){ 118 send_to_page(event); 108 119 } 109 120 }
Note: See TracChangeset
for help on using the changeset viewer.